rahul23111988
BAN USER- 0of 0 votes
AnswersJava runs on a "virtual" stack machine inside JVM, which has instruction of size of one byte (called byte-codes). How many instructions/bytecodes potentially can such a machine have?
- rahul23111988 in United States
PICK ONE OF THE CHOICES
256
Unlimited
2^32 for 32-bit machines
Depends on JVM version| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Java Operating System - 0of 0 votes
AnswersIn a multi-threaded application, many threads are trying to access the same
- rahul23111988 in United States
resource, say a global c ount, g. Threads are synchronized by the following code
(assume lock is a static int variable, initialized to 0 (unlocked state)):
if (lock) wait(); // It's already locked so wait(sleep) till someone wakes me up
else lock=1; // I locked it
/* Critical Section - Increment g */
lock = 0; // Lock released, so wakeup only one of other waiting threads, if any
What is the issue with this synchronization?
PICK ONE OF THE CHOICES
No issues – will work correctly
Works only on a uniprocessor system and would not work on multiprocessor system
Will not work on any system
Cannot say – need more data| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Operating System - 1of 1 vote
AnswersFind the longest path in a binary tree
- rahul23111988 in India
with one bend.
One bend means like SAY I HAVE
1
2 44
3
With one bend means all the nodes means if we start connecting nodes then connect as much as possible in a single line and u can take maximun one bend.Say left left left than right right right.That is maximum one turn..It is not same as diameter say ia have
1
/
2
\
3
Diameter of above is 3 but if we take all the nodes then we will have 2 bends..
So we will two nodes to get nodes with one bend..hope m clear| Report Duplicate | Flag | PURGE
Amazon SDE1
If stack size is 2 bytes.then it will change.so it is depending on stack size as u mentioned it will not depend on stack size?
- rahul23111988 August 22, 2014This is not specific to java..Its a general block of code
- rahul23111988 August 22, 2014Can you give me sone source to read about this.
Is it 256?
@game boy...if we reach prev node..wat does this mean?does it mean the current inorder node with which we are going to swap the node returned by the revrse inorder??correct if m getting it wrng
- rahul23111988 December 06, 2013Guys my idea is same as game boy..do inorder Traversal..n when we access particular node then at that time find the minimum from the tree and swap these two...same as selction sort
- rahul23111988 December 06, 2013I came up with
Consider a BT as an array and apply selection sort.
I will do inorder traversal and while accessing particular node i will call
Inorder_min fxn..
Inorder_min fxn will search the min value from the tree and i will swap it with current index/node.
Now when we encounter the second node then again same fxn will be called and now it will return the secind minimum value and then i will swap these two value and so on..
0(n^2).
Any thoughts on my approach?And any better sol?
If the arrays are sorted we can apply merging step of merge sort and if not sorted theb we can do it by comparing one element with every other..
- rahul23111988 December 05, 2013
Sorry for miscommunication..I got it..
- rahul23111988 August 22, 2014Instruction size will guve number of opcode.