Skip to content
  • Linkedin
  • Youtube
  • Pinterest
  • Home
  • Privacy Policy
  • About
  • Contact
Programmingoneonone

Programmingoneonone

Programmingoneonone is a website that publishes daily tutorials, methods, guides, and articles on IT, Education, and technology.

  • Home
  • Human Values
  • DSA
  • IoT Tutorials
  • Interview Questions and Answers
  • Toggle search form
data structures and algorithms DSA interview questions and answers

Data Structure & Algorithms Interview Questions/Answers

Posted on 19 March 202222 April 2023 By YASH PAL No Comments on Data Structure & Algorithms Interview Questions/Answers

In this article, we are going to see the top most important questions and answers about Data Structures and algorithms. so if you are preparing for competitive exams, or for coding interviews for big companies like Google, Microsoft, Amazon, etc then you must prepare for the Data structures and algorithms questions. So here we are including some basic to advanced questions related to DSA so you can prepare for this topic.

Consider the following tree

Data Structure & Algorithms Interview Questions and Answers

If the post-order traversal gives ab-cd*+ then the label of the nodes 1,2,3,… will be

  1. +,-,*,a,b,c,d
  2. a,-,b,+,*,d
  3. a,b,c,d,d,-,*,+
  4. -,a,b,+,*,c,d

Answer – (1) +,-,*,a,b,c,d

Consider the following tree

Data Structure & Algorithms Interview Questions and Answers

If this tree is used for sorting, then a new number 8 should be placed as the

  1. the left child of the node labeled 30
  2. right child of the node labeled 5
  3. right child of the node labeled 30
  4. the left child of the node labeled 10

Answer – (4) the left child of the node labeled 10

The initial configuration of a queue is a,b,c,d,(‘a’ is in the front end). To get the configuration d,c,b, a, one needs a minimum of

  1. 2 deletions and 3 additions
  2. 3 deletions and 2 additions
  3. 3 deletions and 3 additions
  4. 3 deletions and 4 additions

Answer – (3) 3 deletions and 2 additions

The order of a B-tree is defined as the

  1. Minimum no. of keys in a non-root node
  2. Maximum no. of keys in a non-root node
  3. (n + 1) / 2
  4. Maximum no. of pointers in any node

Answer – (4) Maximum no. of pointers in any node

If the sequence of operations – push(1), push(2), pop, push(1), push(20), pop, pop, pop, push(2), pop, are performed on a stack, the sequence of popped out values are

  1. 2,2,1,1,2
  2. 2,2,1,2,2
  3. 2,1,2,2,1
  4. 2,1,2,2,2

Answer – (1) 2, 2, 1, 1, 2

The depth of a complete binary tree with ‘n’ nodes is (log is to the base two)

  1. log(n + 1) – 1
  2. log(n)
  3. log(n – 1) + 1
  4. log(n) + 1

Answer – (1) log(n + 1) – 1

Preorder is the same as

  1. depth-first order
  2. breadth-first order
  3. topological order
  4. linear order

Answer – (1) depth-first order

Which of the following traversal techniques lists the nodes of a binary search tree in ascending order?

  1. Post-order
  2. In-order
  3. Pre-order
  4. None of the above

Answer – (2) In-order

A hash function f defined as f(key) = key mod 7, with linear probing, is used to insert the keys 37,38,72,48,98,11,56, into a table indexed from 0 to 6. What will be the location of key 11?

  1. 3
  2. 4
  3. 5
  4. 6

Answer – (3) 5

There are 4 different algorithms A1, A2, A3, and A4 to solve a given problem with the order log(n), log(log(n)), nlog(n), and n/logn respectively. Which is the best algorithm?

  1. A1
  2. A2
  3. A4
  4. A3

Answer – (2) A2

The number of possible binary search trees with 3 nodes is

  1. 12
  2. 13
  3. 5
  4. 15

Answer –  (3) 5

Sorting is useful for

  1. report generation
  2. minimizing the storage needs and responding to queries easily
  3. making searching easier and more efficient
  4. all of the above

Answer – (4) all of the above

The order of an algorithm that finds whether a given Boolean function of ‘n’ variables, produces a 1 is

  1. constant
  2. linear
  3. logarithmic
  4. exponential

Answer – (4) exponential

In evaluating the arithmetic expression 2 * 3 – (4 + 5), using stacks to evaluate its equivalent postfix form, which of the following stack configuration is not possible?

Data Structure & Algorithms Interview Questions and Answers

Answer – (d)

The way a card game player arranges his cards as he picks them up one by one is an example of

  1. bubble sort
  2. selection sort
  3. insertion sort
  4. merge sort

Answer – (3) insertion sort

You want to check whether a given set of items is sorted. Which of the following sorting methods will be the most efficient if it is already in sorted order?

  1. Bubble sort
  2. Selection sort
  3. Insertion sort
  4. Merge sort

Answer – (3) insertion sort

Which of the following sorting methods will be the best if a number of swappings are done, is the only measure of efficiency?

  1. bubble sort
  2. selection sort
  3. insertion sort
  4. Quicksort

Answer – (3) insertion sort

You are asked to sort 15 randomly generated numbers. You should prefer

  1. bubble sort
  2. selection sort
  3. insertion sort
  4. Quicksort

Answer – (3) insertion sort

As part of maintenance work, you are entrusted with the work of rearranging the library books on a shelf in proper order, at the end of each day. The ideal choice will be

  1. bubble sort
  2. selection sort
  3. insertion sort
  4. heap sort

Answer – (2) selection sort

Which of the following algorithms exhibits the unnatural behavior that, the minimum number of comparisons are needed if the list to be sorted is in the reverse order and a maximum number of comparisons are needed if they are already in sorted order?

  1. Heapsort
  2. Radix sort
  3. Binary insertion sort
  4. There can’t be any such sorting methods

Answer – (3) Binary insertion sort

Note – more questions and answers will be added from time to time.

Algorithms Tutorials, Data Structures Tutorials, Interview questions answers Tags:computer science, interview preparation

Post navigation

Previous Post: Computer Organization Interview Questions and Answers
Next Post: Database Management Systems Interview Questions/Answers

Related Tutorials

c programming interview questions and answers C Programming Interview Questions and Answers C Programming Tutorials
Insertion in doubly linked list in DSA Insertion in Doubly Linked List Computer Science Tutorials
heap in data structure Heap in Data Structure Computer Science Tutorials
Binary tree in data structure Binary Tree in Data Structure Computer Science Tutorials
tree in data structure and algorithm Tree in Data structure Computer Science Tutorials
priority queue in data structures and algorithms Priority queue in Data structure Computer Science Tutorials

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Pick your Subject

  • Internet of Things
  • Data Structures/Algorithms
  • Interview Preparation
  • Human Values
  • Java Interview Questions and Answers (2023)
    Thinking of becoming a Java developer? I must say it’s a good choice! Java is continuously named the most popular programming language. And the...

    Learn More “Java Interview Questions and Answers (2023)” »

  • Iot(Internet of things) in healthcare
    IoT in Healthcare
    IoMT (Internet of Medical Things) stands for devices that can collect and exchange data – either with users or other devices via the internet,...

    Learn More “IoT in Healthcare” »

  • four stages of iot solution for industry
    IoT for Industry
    In this post, we are going to learn about use cases of IoT for Industry and four stages for providing IoT solutions. Machine Diagnosis...

    Learn More “IoT for Industry” »

  • Iot for agricultural
    IoT in Agriculture
    IoT technology has realized smart wearables, connected devices, automated machines, and driverless cars. However, in agriculture, the IoT has brought the greatest impact. Amongst the challenges...

    Learn More “IoT in Agriculture” »

  • Iot for logistics
    IoT in Logistics and Supply Chain
    IoT applications for smart logistics and supply chain systems:  Logistics Fleet Tracking  To track the locations of the vehicles in real time, the vehicle...

    Learn More “IoT in Logistics and Supply Chain” »

  • Algorithms Tutorials
  • Basic Programming
  • C Programming Tutorials
  • C++ Tutorials
  • Compiler Design Tutorials
  • Computer Networks Tutorials
  • Computer Organization Tutorials
  • Computer Science Tutorials
  • Data Structures Tutorials
  • DBMS Tutorials
  • Developer Guide
  • Digital Communication
  • Digital Logic Tutorials
  • Internet of Things Tutorials
  • Internet Tutorials
  • Interview questions answers
  • Java Tutorials
  • Javascript Tutorials
  • Machine Learning Tutorials
  • Operating Systems Tutorials
  • Programming Tutorials
  • Projects
  • Tips&Tricks
  • Tools
  • VBScript Tutorials
  • Java Interview Questions and Answers (2023)
    Thinking of becoming a Java developer? I must say it’s a good choice! Java is continuously named the most popular programming language. And the...

    Learn More “Java Interview Questions and Answers (2023)” »

  • Iot(Internet of things) in healthcare
    IoT in Healthcare
    IoMT (Internet of Medical Things) stands for devices that can collect and exchange data – either with users or other devices via the internet,...

    Learn More “IoT in Healthcare” »

  • four stages of iot solution for industry
    IoT for Industry
    In this post, we are going to learn about use cases of IoT for Industry and four stages for providing IoT solutions. Machine Diagnosis...

    Learn More “IoT for Industry” »

  • Iot for agricultural
    IoT in Agriculture
    IoT technology has realized smart wearables, connected devices, automated machines, and driverless cars. However, in agriculture, the IoT has brought the greatest impact. Amongst the challenges...

    Learn More “IoT in Agriculture” »

  • Iot for logistics
    IoT in Logistics and Supply Chain
    IoT applications for smart logistics and supply chain systems:  Logistics Fleet Tracking  To track the locations of the vehicles in real time, the vehicle...

    Learn More “IoT in Logistics and Supply Chain” »

Copyright © 2023 Programmingoneonone.

Powered by PressBook Blog WordPress theme