69 CS651 Lecture Notes - Lecture 37: Citrix Systems, Linked List, Merge Sort

4 views2 pages
L37: TOP LINKED LIST INTERVIEW QUESTIONS In
Java | Lesson 37 | DSA In Java | @CodingNinjasIndia
Coding Ninjas
Top link list interview questions in Java by coding Ninjas. In this video we are
going to look at two questions which are asked by various companies, including
Microsoft, Amazon, Google, Facebook and even Citrix. the question says that we
are given a binary linked list integer. we have to tell what does the decimal
representation of the linkage is equal to.. This is a decimal number. Basically the
base is decimal all right so how do we do this so This is quite simple and
straightforward. So let 's see if I have a link list something like 1, 0, 0, 0 and then
1 and then the end functional right so we can say we also. We know the length
of the linked list, so we know that the most significant bit would start from n
minus 1 to n minus 4.. we 'll basically maintain a variable. N which denotes the
most significant bit till now.. While we traverse the linked list, we 'll keep
decrementing n one by one and that 's how we get our answer.. Then we'll make
a integer sum which will store our final result. So while head is not equal to null
sum is Uh add to the sum head. data times 1 left shift Msv..
The time complexity would be big O of n Why because we are only traversing
the whole English one so let 's say I have an increase like this this and this so I
have like one two and so two can right so I will come here. I'll answer I 'll
calculate the answer for this so that would be 1 raised to the power 2. correct
answer all our Hq is passed so I hope you understood the approach to the
problem so I'm not using any extra space so that 's why the space formula will
be constant. So do check out this problem do try to code it on your own Uh and
let's move on to the next problem which is merge sort link list Mer sort
algorithm is based upon the divide and conquer technique which is based on the
divide. the algorithm says. That you know what bring me the answer for some
smaller range combine it with the whole range and then that would be my
answer for the whole problem. like so let 's say I have a link list something like 4,
five, one, six two and three, so the sorted linkage here would look something
like one two, three, four five and then six functional. one can not be further
broken down into half because it is a single node. a single node is always sorted
so for that I 'm going to break down six and two. So six six is now pointing to
null and two again is also now pointing down. now I have finally breaking all the
nodes into single nodes and as your as I said the single nodes are always
sorted..
We 're gon na use a technique that we use earlier in the video how to detect a
loop in a linked list where we use a slow and a fast pointer. the fast node is
basically the node which is being pointed by the fast pointer. So let 's see in with
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Java | lesson 37 | dsa in java | @codingninjasindia. Top link list interview questions in java by coding ninjas. In this video we are going to look at two questions which are asked by various companies, including. Microsoft, amazon, google, facebook and even citrix. the question says that we are given a binary linked list integer. we have to tell what does the decimal representation of the linkage is equal to Basicall y the base is decimal all right so how do we do this so this is quite simple and straightforward. So let "s see if i have a link list something like 1, 0, 0, 0 and then. 1 and then the end functional right so we can say we also. We know the length of the linked list, so we know that the most significant bit would start from n minus 1 to n minus 4 we "ll basically maintain a variable.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions