Hari Krishna Bodicharla Code Interview What is it Books The process The questions How to prepare What is it Code Interview job interview involves designing and writing programs the contents relate to coding ID: 641133
Download Presentation The PPT/PDF document "Code Interview Yingcai Xiao" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Code Interview
Yingcai
Xiao
Hari
Krishna
BodicharlaSlide2
Code Interview
What is it?
Books
The process
The questions
How to prepare?Slide3
What is it?
Code Interview: job interview involves designing and writing programs. (the contents relate to coding.)Slide4
Digital Interview
Digital Interview: online interview, video interview. The format relates to digital media. Can be real-time or pre-recorded. Slide5
Digital Interview
"The Essential Digital Interview Handbook"
by Paul J.
Bailo
online interview,
good reference even for face-to-face interview.Slide6
Books on Code Interview (in Safari)
"
Ace the Programming Interview: 160 Questions and Answers for Success
“
by
Edward
Guiness
"Programming Interviews Exposed: Secrets to Landing Your Next Job"
by
John
Mongan
; Eric
Giguere
; Noah Kindler
"Coding Interviews: Questions, Analysis & Solutions"
by Harry HeSlide7
Books on Code Interview (not in Safari)
"Cracking the Coding Interview: 150 Programming Interview Questions and Answers"
by
Gayle
Laakmann
McDowell
"Cracking the C, C++, and Java Interview"
by
S G
GaneshSlide8
The Process
Usually after HR screening interview
Or after a phone interview
Can be online (digital)
Or face-to-face
Usually one-on-one with your interviewer.
You may have something to write on. Slide9
The Process
You will be asked to write some code.
May need to talk through the question first
May be in an actual programming language
May be as pseudo-code. Slide10
The Questions
Compare two integers without using any comparison operators?Slide11
The Questions
Swap two integers without using a temp?Slide12
The Questions
Which one is faster?
int
I, J = 8;I = 0.5 * J;I = J / 2;I = J >> 1;Slide13
Array
Linked List
Array List
Hash Table Queue Stack Tree Graph
Data StructuresSlide14
Why different data structures?
Use minimum space (Array).
Fast to retrieve (Array).
Easy to search (Array, Indexing / Hashing, Tree). Easy to modify (Linked List). Persistent. (IDs not Pointers/References) Sharable over the Internet. (XML) Reduce coding errors. (Padded Array)
Data StructuresSlide15
Persistent. (IDs not Pointers/References)
There is no use to save pointers/references or transmit them over the Internet.
Serialization (memory automatically allocated during loading)
Use indexes to link data instead of pointers/references (indexed faceset)Data StructuresSlide16
Index Linked
Data StructureSlide17
Data
Structure for Graphics and VisualizationSlide18
Serialization of objectsSlide19
Serialization
Converting an object into a form that can be persisted or transported.
Save objects to permanent storages.Sent over the network. Pass on to another object.Slide20
Deserialization
Converts
a stream into an object. Together
, these processes allow data to be easily stored and transferred.Slide21
Requirements for Serialization
To allow an object to be serializable:
In a serializable class, you must ensure that
every instance variable of the class is also serializable.The class must be visible at the point of serialization.All primitive types are serializable.Slide22
Sample Code for Serialization
// serializable class
class SerializeEmployee
{public: char character; unsigned int id; // serializing method void Serialize(::std::ostream &os); //static deserializing method static SerializeEmployee Deserialize(::std::istream &is);};
void
SerializeEmployee
::Serialize(
std
::
ostream
&
os
)
{
if (
os.good
())
{
os.write
((char*)&character,
sizeof
(character));
os.write
((char*)&id,
sizeof
(id));
}
}Slide23
Sample Code for Deserialization
SerializeEmployee
SerializeEmployee::
Deserialize(std::istream &is){ SerializeEmployee retval; if (is.good()) { is.read((char*)&retval.character, sizeof(retval.character)); is.read((char*)&retval.id, sizeof(retval.id)); } if (
is.fail
()) {
throw ::
std
::
runtime_error
("failed to read full
struct
");
}
return
retval
;
}Slide24
Serialization References
http://
en.wikipedia.org/wiki/Serialization
http://www.slideshare.net/imypraz/java-serialization-8916554?v=qf1&b=&from_search=8http://www.stackoverflow.com/questions/5707835/having-trouble-serializing-binary-data-using-ifstream-and-ofstreamSlide25
Sharable over the Internet. (XML)
Text based
User defined tags
No header InefficientData StructuresSlide26
Reduce coding errors. (Padded Array)
Bounds checker
Use padding cells at the beginning or end of an array.
Error if the padding cells were written to.Data StructuresSlide27
Space Partitioning
Quad Tree (for rectangular shapes)
Triangulation (for irregular shapes)
Data StructuresSlide28
Bubble
Merge
Quick
Heap InsertionSorting