数据结构和算法

DSA - 主页 DSA - 概述 DSA - 环境设置 DSA - 算法基础 DSA - 渐近分析

数据结构

DSA - 数据结构基础 DSA - 数据结构和类型 DSA - 数组数据结构

链接列表

DSA - 链接列表数据结构 DSA - 双向链接列表数据结构 DSA - 循环链表数据结构

堆栈 &队列

DSA - 堆栈数据结构 DSA - 表达式解析 DSA - 队列数据结构

搜索算法

DSA - 搜索算法 DSA - 线性搜索算法 DSA - 二分搜索算法 DSA - 插值搜索 DSA - 跳跃搜索算法 DSA - 指数搜索 DSA - 斐波那契搜索 DSA - 子列表搜索 DSA - 哈希表

排序算法

DSA - 排序算法 DSA - 冒泡排序算法 DSA - 插入排序算法 DSA - 选择排序算法 DSA - 归并排序算法 DSA - 希尔排序算法 DSA - 堆排序 DSA - 桶排序算法 DSA - 计数排序算法 DSA - 基数排序算法 DSA - 快速排序算法

图形数据结构

DSA - 图形数据结构 DSA - 深度优先遍历 DSA - 广度优先遍历 DSA - 生成树

树数据结构

DSA - 树数据结构 DSA - 树遍历 DSA - 二叉搜索树 DSA - AVL 树 DSA - 红黑树 DSA - B树 DSA - B+ 树 DSA - 伸展树 DSA - 尝试 DSA - 堆数据结构

递归

DSA - 递归算法 DSA - 使用递归的汉诺塔 DSA - 使用递归的斐波那契数列

分而治之

DSA - 分而治之 DSA - 最大最小问题 DSA - 施特拉森矩阵乘法 DSA - Karatsuba 算法

贪婪算法

DSA - 贪婪算法 DSA - 旅行商问题(贪婪方法) DSA - Prim 最小生成树 DSA - Kruskal 最小生成树 DSA - Dijkstra 最短路径算法 DSA - 地图着色算法 DSA - 分数背包问题 DSA - 作业排序截止日期 DSA - 最佳合并模式算法

动态规划

DSA - 动态规划 DSA - 矩阵链乘法 DSA - Floyd Warshall 算法 DSA - 0-1 背包问题 DSA - 最长公共子序列算法 DSA - 旅行商问题(动态方法)

近似算法

DSA - 近似算法 DSA - 顶点覆盖算法 DSA - 集合覆盖问题 DSA - 旅行商问题(近似方法)

随机算法

DSA - 随机算法 DSA - 随机快速排序算法 DSA - Karger 最小割算法 DSA - Fisher-Yates 洗牌算法

DSA 有用资源

DSA - 问答 DSA - 快速指南 DSA - 有用资源 DSA - 讨论


Data Structures Algorithms Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to Data Structures Algorithms. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - In order traversal of binary search tree will produce −

A - unsorted list

B - reverse of input

C - sorted list

D - none of the above

Answer : C

Explanation

Binary search tree yields a sorted list when traversed in-order.

Q 2 - push() and pop() functions are found in

A - queues

B - lists

C - stacks

D - trees

Answer : C

Explanation

Stack uses push() to insert an item in stack, and pop() to remove the top item from stack.

Q 3 - Which of the following asymptotic notation is the worst among all?

A - Ο(n+9378)

B - Ο(n3)

C - nΟ(1)

D - 2Ο(n)

Answer : B

Explanation

Ο(n+9378) is n dependent

Ο(n3) is cubic

nΟ(1) is polynomial

2Ο(n) is exponential

Answer : C

Explanation

An algorithm is a step by step procedure to solve a computer problem.

Q 6 - In binary heap, whenever the root is removed then the rightmost element of last level is replaced by the root. Why?

A - It is the easiest possible way.

B - To make sure that it is still complete binary tree.

C - Because left and right subtree might be missing.

D - None of the above!

Answer : B

Explanation

A binary heap (whether max or min) has to satisfy the property of complete binary tree at all times.

Q 7 - Which of the following is not possible with an array in C programming langauge −

A - Declaration

B - Definition

C - Dynamic Allocation

D - Array of strings

Answer : C

Explanation

Array in C are static and cannot be shrinked or expanded in run-time.

Answer : B

Explanation

Recursion uses stack but the main reason is, every recursive call needs to be stored separately in the memory.

Q 9 - If we choose Prim's Algorithm for uniquely weighted spanning tree instead of Kruskal's Algorithm, then

A - we'll get a different spanning tree.

B - we'll get the same spanning tree.

C - spanning will have less edges.

D - spanning will not cover all vertices.

Answer : B

Explanation

Regardless of which algorithm is used, in a graph with unique weight, resulting spanning tree will be same.

Q 10 - Which of the following algorithm does not divide the list −

A - linear search

B - binary search

C - merge sort

D - quick sort

Answer : A

Explanation

Linear search, seaches the desired element in the target list in a sequential manner, without breaking it in any way.

data_structures_algorithms_questions_answers.htm