DSA (binary tree, selection, bubble)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Disadvantages of bubble sort:

1. Bubble sort has a time complexity of O(N2) which makes it very slow for large data sets. 2. Bubble sort is a comparison-based sorting algorithm, which means that it requires a comparison operator to determine the relative order of elements in the input data set. It can limit the efficiency of the algorithm in certain cases.

Binary Tree node contains the following parts:

1. Data 2. Pointer to left child 3. Pointer to right child

main applications of trees include:

1. Manipulate hierarchical data. 2. Make information easy to search (see tree traversal). 3. Manipulate sorted lists of data. 4. As a workflow for compositing digital images for visual effects. 5. Router algorithms 6. Form of multi-stage decision-making (see business chess).

AUXILIARY OPERATION ON BINARY TREE:

1. finding the height 2. finding the level 3. finding the size of the entire tree

types of binary tree

1. full binary tree 2. complete binary tree 3. Perfect binary tree

BASIC OPERATION ON BINARY TREE:

1. inserting 2. removing 3. searching 4. traversing

Advantages of bubble sort:

1. it is easy to understand and implement 2. it does not require any additional memory space 3. It is a stable sorting algorithm, meaning that elements with the same key value maintain their relative order in the sorted output.

The algorithm maintains two subarrays in a given array

1. the subarray which already sorted 2. the remaining subarray was unsorted

Full binary tree

A Binary Tree is a ____________ if every node has 0 or 2 children.

leaf

A node that has no child; the last node of the tree

complete binary tree

All the levels are completely filled except possibly the last level and the last level has all keys as left as possible.

A complete binary tree is just like a full binary tree, but with two major differences:

Every level must be completely filled • All the leaf elements must lean towards the left. • The last leaf element might not have a right sibling i.e., a complete binary tree doesn't have to be a full binary tree

edge

acts as a link between the parent node and the child node.

Perfect binary tree

all the internal nodes have two children and all leaf nodes are at the same level

Binary tree

defined as a Tree data structure with at most 2 children

TREE

is a popular data structure that is non-linear in nature

Binary tree representation

is represented by a pointer to the topmost node of the tree. If the tree is empty, then the value of the root is NULL.

height

is the distance from that node to the deepest node of that subtree

height of tree

is the maximum height of any node.

bubble sort

is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order.

Selection Sort

Sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning.

subtree

The ______ of a node is the tree considering that particular node as the root node

depth

the ____ of the node is the distance from the root node to that particular node.

root

the topmost node of the tree that has no parent node.


संबंधित स्टडी सेट्स

WGU C193 Client Server Vocab, c193 pt 7, c193 pt 5, c193 pt 9, c193 pt 4, c193 pt 2, C193, c193 pt 3, C193 part 1

View Set

Management of Patients with Oncologic Disorders (15) PrepU

View Set

HY 102 Test 2 Inquisitive Questions

View Set

Priority Setting Frameworks Beginning Test

View Set

Chapter 20 California Life Insurance

View Set

INSY 3330 e-Commerce Final Exam (all quizzes combined)

View Set

Gilded Age, Gilded Age, The Gilded Age

View Set