Aspire Faculty ID #18769 · Topic: UGC NET Computer Science Sep 2022 (Paper II) · Just now
UGC NET Computer Science Sep 2022 (Paper II)

How many rotations are required during the construction of an AVL tree if the following elements are to be added in the given sequence?

$35,50,40,25,30,60,78,20,28$

Solution

Insert elements one by one in AVL tree.

Insert $35$:

Tree is balanced. No rotation.

Insert $50$:

$50$ becomes right child of $35$.

Tree is balanced. No rotation.

Insert $40$:

$40$ goes to left of $50$.

This creates Right-Left imbalance at $35$.

For Right-Left case, we do:

Right rotation at $50$

Left rotation at $35$

So far:

Left rotations $=1$

Right rotations $=1$

Insert $25$:

$25$ goes to left side.

Tree remains balanced. No rotation.

Insert $30$:

$30$ goes to right of $25$.

This creates Left-Right imbalance at $35$.

For Left-Right case, we do:

Left rotation at $25$

Right rotation at $35$

Now total:

Left rotations $=2$

Right rotations $=2$

Insert $60$:

$60$ goes to right side.

Tree remains balanced. No rotation.

Insert $78$:

$78$ goes to right of $60$.

This creates Right-Right imbalance at $50$.

For Right-Right case, we do:

Left rotation at $50$

Now total:

Left rotations $=3$

Right rotations $=2$

Insert $20$:

$20$ goes to left side.

Tree remains balanced. No rotation.

Insert $28$:

$28$ goes to right of $25$.

Tree still remains balanced. No rotation.

Therefore, total rotations are:

$3$ left rotations and $2$ right rotations.

Previous 10 Questions — UGC NET Computer Science Sep 2022 (Paper II)

Nearest first
1
Consider the traversal of a treePreorder $\to ABCEIFJDGHKL$Inorder $\to EICFJBGDKHLA$Which of the following is correct …
Topic: UGC NET Computer Science Sep 2022 (Paper II)
2
Consider the hash table of size $11$ that uses open addressing with linear probing. Let $h(k)=k\mod 11$ be the hash fun…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
3
Which of the following algorithm design approach is used in Quick sort algorithm?
Topic: UGC NET Computer Science Sep 2022 (Paper II)
4
Consider a B-tree of height $h$ minimum degree $t\ge 2$ that contains any $n$-key, where $n\ge 1$. Which of the followi…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
5
The number of nodes of height $h$ in any $n$-element heap is atmost:
Topic: UGC NET Computer Science Sep 2022 (Paper II)
6
The solution of the recurrence relation $T(n)=3T\left(\frac{n}{4}\right)+n\log n$ is
Topic: UGC NET Computer Science Sep 2022 (Paper II)
7
Assume that $f(n)$ and $g(n)$ are asymptotically positive. Which of the following is correct?
Topic: UGC NET Computer Science Sep 2022 (Paper II)
8
Which of the following is correct for the destination address $4A:30:10:21:10:1A$?
Topic: UGC NET Computer Science Sep 2022 (Paper II)
9
A $4$-stage pipeline has a stage delay of $150,120,160$ and $140$ ns respectively. Registers that are used between the …
Topic: UGC NET Computer Science Sep 2022 (Paper II)
10
Which layer divides each message into packets at the source and re-assembles them at the destination?
Topic: UGC NET Computer Science Sep 2022 (Paper II)

Next 10 Questions — UGC NET Computer Science Sep 2022 (Paper II)

Ascending by ID
1
Consider the following two lists:List IList II(A) Stack overflow(I) Software Interrupt(B) Timer(II) Internal interrupt(…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
2
Let $R(ABCDEFGH)$ be a relation schema and $F$ be the set of dependencies$F=\{A\to B,\ ABCD\to E,\ EF\to G,\ EF\to H,\ …
Topic: UGC NET Computer Science Sep 2022 (Paper II)
3
A trigger is
Topic: UGC NET Computer Science Sep 2022 (Paper II)
4
For the following page reference string $4,3,2,1,4,3,5,4,3,2,1,5$, the number of page faults that occur in the least Re…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
5
A magnetic tape drive has a transport speed of $200$ inches per second and a recording density of $1600$ bytes per inch…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
6
Consider two lists A and B of three strings on $\{0,1\}$X:List AList B11111011110100Y:List AList B1010101111101011Which…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
7
Consider the properties of recursively enumerable sets:(A) Finiteness(B) Context Freedom(C) EmptinessWhich of the follo…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
8
Consider the following : List IList II(A) Activation record(I) Linker Loader(B) Location counter(II) Garbage Collection…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
9
 Consider the following related to Fourth Generation Technique $(4GT)$:(A) It controls efforts.(B) It controls res…
Topic: UGC NET Computer Science Sep 2022 (Paper II)
10
Consider the grammar $S\to SbS\mid a$.Consider the following statements:The string $abababa$ has(A) two parse trees(B) …
Topic: UGC NET Computer Science Sep 2022 (Paper II)
Ask Your Question or Put Your Review.

loading...