YouTube Icon

Interview Questions.

Top 100+ Data Structure & Algorithms Interview Questions And Answers - May 29, 2020

fluid

Top 100+ Data Structure & Algorithms Interview Questions And Answers

Question 1. What Is An Avl Tree?

Answer :

AVL bushes are top balancing binary seek tree. AVL tree exams the peak of left and right sub-bushes and assures that the distinction isn't more than 1. This distinction is known as Balance Factor.

BalanceFactor = top(left-sutree) − peak(right-sutree)

Question 2. What Is A Spanning Tree?

Answer :

A spanning tree is a subset of Graph G, which has all of the vertices blanketed with minimum feasible variety of edges. A spanning tree does not have cycles and it can't be disconnected.

RDBMS Interview Questions
Question three. How Many Spanning Trees Can A Graph Has?

Answer :

It depends on how related the graph is. A complete undirected graph may have maximum nn-1 number of spanning trees, in which n is quantity of nodes.

Question four. How Kruskal's Algorithm Works?

Answer :

This set of rules treats the graph as a wooded area and each node it as an person tree. A tree connects to any other best and only if it has least price amongst all to be had options and does now not violate MST houses.

Adv Java Tutorial
Question 5. How Prim's Algorithm Finds Spanning Tree?

Answer :

Prim's set of rules treats the nodes as a unmarried tree and maintains on adding new nodes to the spanning tree from the given graph.

DBMS Interview Questions
Question 6. What Is A Minimum Spanning Tree (mst) ?

Answer :

In a weighted graph, a minimal spanning tree is a spanning tree that has minimum weight that every one other spanning timber of the same graph.

Question 7. What Is A Heap In Data Structure?

Answer :

Heap is a special balanced binary tree statistics structure wherein root-node secret's compared with its children and arranged hence. A min-heap, a determine node has key value less than its childs and a max-heap determine node has cost more than its childs.

Core Java Tutorial Adv Java Interview Questions
Question eight. What Is A Recursive Function?

Answer :

A recursive characteristic is one that calls itself, immediately or calls a feature that during flip calls it. Every recursive function follows the recursive residences − base criteria in which functions stops calling itself and revolutionary technique where the features attempts to fulfill the bottom standards in every iteration.

Question nine. What Is Data-structure?

Answer :

Data shape is a manner of defining, storing & retriving of records in a structural & systemetic way. A facts structure can also comprise one of a kind type of information items.

Core Java Interview Questions
Question 10. What Are Various Data-structures Available?

Answer :

Data shape availability may range by means of programming languages. Commonly to be had records systems are list, arrays, stack, queues, graph, tree and so forth.

C Tutorial
Question 11. What Is Algorithm?

Answer :

Algorithm is a step by step technique, which defines a set of instructions to be completed in certain order to get the preferred output.

C Interview Questions
Question 12. Why We Need To Do Algorithm Analysis?

Answer :

A problem can be solved in a couple of approaches. So, many answer algorithms may be derived for a given hassle. We analyze available algorithms to find and put into effect the first-class suitable set of rules.

RDBMS Interview Questions
Question thirteen. What Are The Criteria Of Algorithm Analysis?

Answer :

An set of rules are typically analyzed on two factors − time and area. That is, how an awful lot execution time and what sort of more area required by way of the algorithm.

CSS Advanced Tutorial
Question 14. What Is Asymptotic Analysis Of An Algorithm?

Answer :

Asymptotic analysis of an algorithm, refers to defining the mathematical boundation/framing of its run-time performance. Using asymptotic evaluation, we will thoroughly finish the exceptional case, common case and worst case scenario of an set of rules.

Question 15. What Are Asymptotic Notations?

Answer :

Asymptotic evaluation can provide three levels of mathematical binding of execution time of an algorithm −

Best case is represented by Ω(n) notation.
Worst case is represented with the aid of Ο(n) notation.
Average case is represented with the aid of Θ(n) notation.
Database Administration Interview Questions
Question 16. What Is Linear Data Structure?

Answer :

A linear information-structure has sequentially arranged information gadgets. The subsequent time may be positioned in the subsequent memory deal with. It is stored and accessed in a sequential manner. Array and listing are example of linear data structure.

Maven Tutorial
Question 17. What Are Common Operations That Can Be Performed On A Data-shape?

Answer :

The following operations are typically finished on any statistics-structure −

Insertion − adding a facts item
Deletion − casting off a information item
Traversal − accessing and/or printing all information gadgets
Searching − finding a specific facts item
Sorting − arranging statistics gadgets in a pre-defined sequence
CSS Advanced Interview Questions
Question 18. Briefly Explain The Approaches To Develop Algorithms?

Answer :

There are 3 generally used tactics to increase algorithms:

Greedy Approach − finding answer by means of selecting next fine option
Divide and Conquer − diving the trouble to a minimum possible sub-hassle and fixing them independently
Dynamic Programming − diving the problem to a minimum viable sub-hassle and solving them combinedly
DBMS Interview Questions
Question 19. Give Some Examples Greedy Algorithms?

Answer :

The under given problems discover their answer the use of grasping algorithm approach:

Travelling Salesman Problem
Prim's Minimal Spanning Tree Algorithm
Kruskal's Minimal Spanning Tree Algorithm
Dijkstra's Minimal Spanning Tree Algorithm
Graph - Map Coloring
Graph - Vertex Cover
Knapsack Problem
Job Scheduling Problem
Object Oriented Analysis and Design Tutorial
Question 20. What Are Some Examples Of Divide And Conquer Algorithms?

Answer :

The under given problems locate their answer the usage of divide and triumph over set of rules technique :

Merge Sort
Quick Sort
Binary Search
Strassen's Matrix Multiplication
Closest pair (points)
Maven Interview Questions
Question 21. What Are Some Examples Of Dynamic Programming Algorithms?

Answer :

The underneath given troubles find their solution using divide and overcome set of rules approach:

Fibonacci wide variety collection
Knapsack hassle
Tower of Hanoi
All pair shortest route by using Floyd-Warshall
Shortest course through Dijkstra
Project scheduling
Question 22. What Is A Linked-listing?

Answer :

A linked-listing is a listing of statistics-objects linked with hyperlinks i.E. Recommendations or references. Most cutting-edge excessive-level programming language does no longer offer the function of at once accessing memory region, therefore, linked-list aren't supported in them or available in shape of built in features.

Question 23. What Is Stack?

Answer :

In facts-shape, stack is an Abstract Data Type (ADT) used to keep and retrieve values in Last In First Out approach.

Computer architecture Interview Questions
Question 24. Why Do We Use Stacks?

Answer :

Stacks follows LIFO approach and addition and retrieval of a facts object takes simplest Ο(n) time. Stacks are used in which we need to get admission to information in the reverse order or their arrival. Stacks are used normally in recursive feature calls, expression parsing, depth first traversal of graphs and so forth.

Adv Java Interview Questions
Question 25. What Operations Can Be Performed On Stacks?

Answer :

The under operations may be finished on a stack:

push() − adds an item to stack
pop() − eliminates the top stack item
peek() − gives value of top object with out removing it
isempty() − checks if stack is empty
isfull() − assessments if stack is full
Question 26. What Is A Queue In Data-shape?

Answer :

Queue is an abstract records shape, incredibly much like stack. In assessment to stack, queue is opened at both quit. One cease is usually used to insert records (enqueue) and the other is used to do away with information (dequeue). Queue follows First-In-First-Out method, i.E., the records object saved first could be accessed first.

Object Oriented Analysis and Design Interview Questions
Question 27. Why Do We Use Queues?

Answer :

As queues follows FIFO approach, they're used whilst we need to paintings on facts-objects in genuine collection of their arrival. Every running machine keeps queues of diverse techniques. Priority queues and breadth first traversal of graphs are a few examples of queues.

Core Java Interview Questions
Question 28. What Operations Can Be Performed On Queues?

Answer :

The under operations can be completed on a stack:

enqueue() − adds an item to rear of the queue
dequeue() − gets rid of the object from front of the queue
peek() − offers price of front object without removing it
isempty() − assessments if stack is empty
isfull() − exams if stack is complete
Question 29. What Is Linear Searching?

Answer :

Linear search attempts to discover an object in a sequentially organized statistics type. These sequentially arranged information items known as array or list, are accessible in incrementing memory area. Linear seek compares anticipated information object with every of statistics gadgets in listing or array. The average case time complexity of linear search is Ο(n) and worst case complexity is Ο(n2). Data in target arrays/lists need now not to be sorted.

Standard Template Library (STL) Interview Questions
Question 30. What Is Binary Search?

Answer :

A binary seek works simplest on taken care of lists or arrays. This seek selects the center which splits the complete listing into two elements. First the middle is compared.

This seek first compares the target cost to the mid of the listing. If it is not observed, then it takes choice on whether or not.

Question 31. What Is Bubble Sort And How Bubble Sort Works?

Answer :

Bubble sort is evaluation primarily based set of rules in which each pair of adjoining factors is as compared and factors are swapped if they may be not so as. Because the time complexity is Ο(n2), it isn't suitable for huge set of records.

Question 32. Tell Me Something About 'insertion Sort'?

Answer :

Insertion kind divides the list into two sub-listing, taken care of and unsorted. It takes one detail at time and reveals it appropriate vicinity in taken care of sub-listing and insert there. The output after insertion is a taken care of sub-list. It iteratively works on all of the factors of unsorted sub-list and inserts them to sorted sub-listing so as.

Xml Publisher Interview Questions
Question 33. What Is Selection Sort?

Answer :

Selection sort is in-region sorting method. It divides the information set into two sub-lists: looked after and unsorted. Then it selects the minimum element from unsorted sub-list and locations it into the looked after listing. This iterates until all the factors from unsorted sub-list are ate up into sorted sub-list.

C Interview Questions
Question 34. How Insertion Sort And Selection Sorts Are Different?

Answer :

Both sorting strategies continues  sub-lists, looked after and unsorted and both take one element at a time and places it into looked after sub-list. Insertion kind works at the modern element in hand and places it inside the looked after array at appropriate area retaining the residences of insertion type. Whereas, choice sort searches the minimal from the unsorted sub-list and replaces it with the cutting-edge detail in hand.

Question 35. What Is Merge Sort And How It Works?

Answer :

Merge sort is sorting algorithm based totally on divide and overcome programming method. It keeps on dividing the listing into smaller sub-list till all sub-listing has simplest 1 detail. And then it merges them in a taken care of manner till all sub-lists are consumed. It has run-time complexity of Ο(n log n) and it needs Ο(n) auxiliary space.

Question 36. What Is Shell Sort?

Answer :

Shell sort can be said a version of insertion kind. Shell kind divides the list into smaller sublist based on a few hole variable after which each sub-listing is looked after the use of insertion kind. In first-rate instances, it could perform upto Ο(n log n).

Database Administration Interview Questions
Question 37. How Quick Sort Works?

Answer :

Quick type uses divide and triumph over method. It divides the listing in smaller 'walls' the usage of 'pivot'. The values which might be smaller than the pivot are arranged within the left partition and extra values are arranged within the proper partition. Each partition is recursively looked after the usage of brief kind.

Question 38. What Is A Graph?

Answer :

A graph is a pictorial representation of a fixed of items wherein some pairs of gadgets are connected by means of hyperlinks. The interconnected items are represented by using factors termed as vertices, and the hyperlinks that connect the vertices are called edges.

Question 39. How Depth First Traversal Works?

Answer :

Depth First Search algorithm(DFS) traverses a graph in a depthward movement and makes use of a stack to take into account to get the subsequent vertex to begin a seek whilst a dead stop takes place in any iteration.

Question forty. How Breadth First Traversal Works?

Answer :

Breadth First Search set of rules(BFS) traverses a graph in a breadthwards motion and uses a queue to recollect to get the next vertex to start a search when a dead stop occurs in any new release.

CSS Advanced Interview Questions
Question 41. What Is A Tree?

Answer :

A tree is a minimally related graph having no loops and circuits.

Question forty two. What Is A Binary Tree?

Answer :

A binary tree has a special condition that every node can have  youngsters at most.

Maven Interview Questions
Question forty three. What Is A Binary Search Tree?

Answer :

A binary seek tree is a binary tree with a unique provision in which a node's left toddler ought to have price less than its determine's value and node's right infant ought to have value greater than it is determine value.

Question forty four. What Is Tree Traversal?

Answer :

Tree traversal is a procedure to go to all of the nodes of a tree. Because, all nodes are related thru edges (links) we usually begin from the root (head) node.

There are 3 ways which we use to traverse a tree:

In-order Traversal
Pre-order Traversal
Post-order Traversal
Question 45. What Is Tower Of Hanoi?

Answer :

Tower of Hanoi, is a mathematical puzzle which consists of 3 tower (pegs) and more than one earrings. All jewelry are of various size and stacked upon every other where the large disk is usually beneath the small disk. The purpose is to move the tower of disk from one peg to every other, without breaking its properties.

Question 46. What Is Fibonacci Series?

Answer :

Fibonacci Series generates next number by means of adding  previous numbers. For example − zero 1 1 2 three 5 eight thirteen.

Question 47. What Is Hashing?

Answer :

Hashing is a way to convert quite a number key values into a variety of indexes of an array. By the use of hash tables, we can create an associative records garage in which information index may be discover with the aid of presenting its key values.

Question forty eight. What Is Interpolation Search Technique?

Answer :

Interpolation seek is an progressed variant of binary search. This seek algorithm works at the probing function of required price.

Question forty nine. What Is The Prefix And Post Fix Notation Of (a + B) * (c + D) ?

Answer :

Prefix Notation − * + a b + c d

Postfix Notation − a b + c d + *




CFG