Computer Knowledge

Data Structures and Algorithms

1,518 Questions

Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.

Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity

Data Structures and Algorithms Questions

Multiple choice
  1. unordered list

  2. ordered list

  3. nested list

  4. definition list

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A bulleted list is called an unordered list in HTML because the items don't need to appear in any specific sequence. It's created using the ul tag with li elements for each item.

Multiple choice
  1. push(@Countries, "Canada") will add new country "Canada" at the beginning of the array @Countries

    Now @Country gives @Countries = ("Canada", "India", "Denmark", "Russia", "Germany", "Japan", "Ireland")

  2. push(@Countries, "Canada") will add new country "Canada" at the end of the array @Countries

    Now @Countries gives @Countries = ("India", "Denmark", "Russia", "Germany", "Japan", "Ireland", "Canada")

  3. pop(@Countries, "India") will remove country "India" from the array @Countries

    Now @Countries looks like @Countries = ("Denmark", "Russia", "Germany", "Japan", "Ireland")

  4. pop(@Countries, "Ireland") will remove the country "Ireland" from the array @Countries

    Now @Countries looks like @Countries = ("India", "Denmark", "Russia", "Germany", "Japan")

  5. pop(@Countries) will remove the country "Ireland" last element of the array @Countries

    Now @Countries looks like @Countries = ("India", "Denmark", "Russia", "Germany", "Japan")

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Yes, Push function on array will add element at the end of the array Yes, pop function removes one element at the end of the array. It has only one argument, i.e., Array Name..

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the correct answer as there are 3 constructors of ArrayList class in Java Collections, viz. ArrayList(): creates an empty constructor with default initial capacity; ArrayList(c : collection): creates an arraylist from existing collection c; and ArrayList(x int): creates an arraylist with initial capacity x. So, this is the correct answer.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer. There are 4 constructors of Vector class, viz. Vector(): creates a default vector with initial capacity 10; Vector(c : collections): creates a vector from existing collection; Vector(initialcapacity int): creates a vector with specified initial capacity; and Vector(initialcapacity int,increment int): creates a vector with specified initial capacity and increment. So, this is the correct answer.

Multiple choice
  1. In a stack, data is stored from only one side. It is called 'top of stack'.

  2. At a time only one item can be inserted or deleted in a stack.

  3. In a stack, after insertion operation, the value of top is decremented.

  4. Stack is a linear data structure.

  5. Stack is called LIFO [last in first out].

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

It is not a true statement about a stack. Since in a stack after insertion operation, the value of top is incremented.

Multiple choice
  1. In a queue, data is inserted from the front end of the queue.

  2. In a queue after insertion and deletion operations, value of front end and rear end is incremented, respectively.

  3. Queue is called FIFO [First in first out].

  4. At a time, only one item can be inserted or deleted in a queue.

  5. Queue is a linear data structure.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is a wrong answer. Since in a queue, data is inserted from the rear end of the queue and is deleted from the front end of the queue.

Multiple choice
  1. Values of in the left subtree are less than root.

  2. Values of in the right subtree are greater than or equal to the root.

  3. Each subtree is itself a binary search tree.

  4. They do not have a recursively defined data structure.

  5. The nodes at the lowest levels of the tree are known as leaves.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the wrong answer since they have a recursively defined data structure.

Multiple choice
  1. Insertion sort

  2. Quick sort

  3. Selection sort

  4. Bubble sort

  5. Binary search

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

It is a right answer since it is based on 'divide and conquer' method, which requires a middle element. Pivot is used for this.

Multiple choice
  1. any element is inserted into the data structure

  2. any element is deleted from the data structure

  3. a data structure is empty and you are trying to delete any element from it

  4. a data structure is full and you are trying to insert any element into it

  5. a data structure is half empty

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the right operation. This condition is called overflow.