0% found this document useful (0 votes)
275 views7 pages

Problem Statement For B-Tree: Functionalities: Insertion

The document discusses problem statements for several data structures and algorithms: - B-tree operations like insertion and deletion, which involve splitting nodes and rebalancing the tree. - Insertion in B-trees, which may require splitting full nodes and moving keys up the tree. - AVL trees, which use rotations to maintain balance during insertion, search, and deletion. - Threaded binary trees, where null pointers are replaced with threads to predecessors/successors. - Minimum spanning tree algorithms like Prim's and Kruskal's, which find minimum weight spanning trees. - The knapsack problem of filling a knapsack with most valuable items under a weight limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
275 views7 pages

Problem Statement For B-Tree: Functionalities: Insertion

The document discusses problem statements for several data structures and algorithms: - B-tree operations like insertion and deletion, which involve splitting nodes and rebalancing the tree. - Insertion in B-trees, which may require splitting full nodes and moving keys up the tree. - AVL trees, which use rotations to maintain balance during insertion, search, and deletion. - Threaded binary trees, where null pointers are replaced with threads to predecessors/successors. - Minimum spanning tree algorithms like Prim's and Kruskal's, which find minimum weight spanning trees. - The knapsack problem of filling a knapsack with most valuable items under a weight limit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Problem Statement for B- tree

Introduction:​ A B-tree is a generalization of a binary search tree. In general B-tree’s are


optimized for large blocks of data and are commonly used in file systems and databases.
Unlike a binary-tree, each node of a B-tree may have a variable number of keys and
children. The keys are stored in non-decreasing order. Each key has an associated child that is
the root of a sub tree containing all nodes with keys less than or equal to the key but
greater than the preceding key. A node also has an additional rightmost child that is the root for a
sub tree containing all keys greater than any keys in the node.

FUNCTIONALITIES:
● INSERTION-
I​ t is used to insert a key into the B tree at a particular location. First check the
boundary conditions i.e count of keys is less than order of the trees and​ ​split the node if
count becomes greater than MAX. Then ​ a check for duplicate values is made and if number of
nodes at a particular level are less than the order of the tree, this functions inserts the value in
appropriate node.

● DELETION-
​It is used to delete a particular key from the B tree. ​First of all it is found out that whether the
value to be deleted is present in the tree or not. If the entry to be deleted is not in the tree then
it is replaced by its successor(predecessor).
A clear operation deletes the key . ​If deletion of a value causes a node to be less
than half full, it is combined with it neighboring nodes, and this can also propagate all
the way to the root.
A Leftshift operation borrow a key from the left neighbouring node if it has atleast (N+1)
keys. And a ,rightshft operation Borrow a key from the right neighbouring node if it has atleast
(N+1) keys.

● DISPLAY- ​it displays the Btree

Problem Statement for Insertion In B- tree

Introduction:
Inserting a key in B-Tree is complicated then inserting a key in binary tree. With a B-tree ,
we cannot create a leaf node and insert it resulting tree would fail to be a valid B-tree. Instead ,
we insert the new key into an existing leaf node. If the leaf node is full then we introduce an
operation that splits node y having (2t-1)keys around its median key ​into two nodes having
(t-1) keys each. The ​median key moves up into y’s parent to identify the dividing point between
the two new trees. If y’ s parent is also full then we split the tree before we insert the new key.
​Functionalities:

● Insert
First of all​ ​status of the node to be inserted a value onto is obtained then search
the position where insertion have to be done and insert the value.

● ​Show-
It display the new btree on the console

Problem Statement for AVL tree

Introduction: ​AVL trees are invented by two Russian mathematicians Adel’son-Vel’skii and Landis in
1962. AVL tree was published in the paper named ”An algorithm for the organisation information”. AVL
tree is a balanced binary search tree which employees rotation to maintain balance.

Purpose​: Binary Search tree can become badly unbalanced. So a balanced Binary Search tree like AVL
tree can be used. AVL trees are always balanced. In worst case Binary Search tree takes O(n) for insert,
search and delete operations. AVL tree takes O(log n) for insert, search and delete operations in both
best and worst cases. The height of Binary Search tree is O(n) in worst case. But the height of AVL tree is
O(log n) in worst case.

Functionalities: ​There are three basic operations in an AVL tree.

1 . Insert : Inserting a node ’n’ into an AVL tree changes the height of some nodes in the tree. The only
nodes whose heights can increase are the ancestors of node ’n’. If the insertion causes the tree to
become unbalanced then some ancestors of ’n’ would have a height imbalance. After the insertion of a
node the tree need to rotated only
once.
2 . Search : The Search operation in AVL tree is same as in case of Binary search tree. The Search
operation can be performed with the key value that need to be searched in the given AVL tree.The
search operation returns a node from a tree if the node value matches with the key value. If the key
value does not match with any node value inthe tree no value is returned.
3 . Displaying the avl tree

Problem Statement for threaded binary tree


1. Introduction: ​A binary tree is threaded by making all right child pointers that would normally be null
point to the inorder successor of the node, and all left child pointers that would normally be null
point to the inorder predecessor of the node.
2. Problem Statement: ​You are given a threaded binary tree where each node of a tree points to some
node to the right of it in in-order traversal. Given such tree, check whether each thread pointer of
the node in a tree satisfies this condition( i.e check whether if thread pointer is pointing to node that
is on the right side in in-order traversal). If not make that pointer NULL else leave it.
Each node has only three pointers pointing to left, right nodes and other the thread pointer. Space
and Time constraint has to be considered while designing it.

Problem Statement For PRIM’S Algorithm

1. Introduction :
A ​spanning tree​ of an undirected graph ​G​ is a subgraph of ​G​ that is a tree containing all
the vertices of ​G.​ In a weighted graph, the weight of a subgraph is the sum of the weights
of the edges in the subgraph.
A ​minimum spanning tree​ (MST) for a weighted undirected graph is a spanning tree with
minimum weight.
2. Purpose : ​Prim's purpose is to find a minimum spanning.
3. Definitions​: Prim’s algorithm is a greedy algorithm which is used to solve the M.S.T
problem of a connected weight graph G with n vertices. The algorithm starts by
initializing a tree T=(V,E) with one vertex V=​v​. Define a set ​ET ​as the set of edges that
have one end point in V and other endpoint in ​V.​ the algorithm repeats the operation of
adding the edge in ​ET ​with minimum weight to E, and the endpoint in ​V. ​to V. this
repetition terminates when T has n vertices or equivalently has (n-1) edges.

Problem Statement For Kruskal Algorithm

1. Introduction :

A ​spanning tree​ of an undirected graph ​G​ is a subgraph of ​G​ that is a tree containing all
the vertices of ​G​.
In a weighted graph, the weight of a subgraph is the sum of the weights of the edges in
the subgraph.
A ​minimum spanning tree​ (MST) for a weighted undirected graph is a spanning tree with
minimum weight.

2. Purpose : ​Kruskal's purpose is to find a minimum spanning

3. 3. ​Definitions ​Kruskal's algorithm​ is an algorithm in graph theory that finds a minimum


spanning tree for a connected weighted graph. This means it finds a subset of the edges that
forms a tree that includes every vertex, where the total weight of all the edges in the tree is
minimized. If the graph is not connected, then it finds a ​minimum spanning forest​ (a minimum
spanning tree for each connected component). Kruskal's algorithm is an example of a greedy
algorithm
Problem Statement For KnapSack problem

Introduction :​The ​knapsack problem​ or ​rucksack problem​ is a problem in combinatorial optimization:


Given a set of items, each with a weight and a value, determine the count of each item to include in a
collection so that the total weight is less than or equal to a given limit and the total value is as large as
possible. It derives its name from the problem faced by someone who is constrained by a fixed-size
knapsack and must fill it with the most useful items.
Purpose : ​The objective is to pick some of the items, with maximal total profit, while obeying that the
maximum total weight of the chosen items must not exceed ​W.​
​Problem
A thief robbing a store finds n items; the ith item is worth vi dollars and weights wi

pounds. He wants to take as valuable a load as possible, but he can carry at most W pounds

in his knapsack. What items should be taken?

Formally, the problem can be stated as follows:

Input:​ n items of values ​v1 ,v2 ,... ,v n​ and of the weight ​ w1 ,w2 ,... ,wn ​, and a

total weight W , where​ vi , w i​ and W are positive integers.

Output: a subset S ​⊆​ {1, 2,... ,n} of the items such that

​i∈Swi​≤​W​ and ​i∈Svi​ is maximized.

This is called the 0-1 knapsack problem because each item must either be taken or left

behind; the thief cannot take a fractional amount of an item or take an item more than once.

The knapsack problem is an abstraction of many real problems, from investing to telephone

routing.

Functionalities:

● Knapsack problem

First a menu is to be displayed so that concerned functions can be called then


calculate the limit on the maximum weight of the items that can be chosen. Ratio is
calculated and sorted in the increasing order. ​When you again enter the shop you have
looted once before​ ,​ a message appears that you are busted. Result is displayed if you are
not busted. Finally memory is freed before thief can enter into new shop. A help menu
is also available to display the startup.
Problem Statement For TIC TAC TOE problem

Introduction :

The friendliness of tic-tac-toe games makes them ideal as a pedagogical tool for teaching the concepts of
good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees.
It is straightforward to write a computer program to play tic-tac-toe perfectly, to enumerate the 765
essentially different positions

Players soon discover that best play from both parties leads to a draw (often referred to as cat or cat's
game). Hence, tic-tac-toe is most often played by young children.
Tic-tac-toe​, also called ​noughts and crosses ​is a pencil-and-paper game for two players, ​X​ and
O​, who take turns marking the spaces in a 3×3 grid. The ​X​ player usually goes first. The player
who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the
game.
The following example game is won by the first player, X:

Functionalities:

● Tic Tac Toe problem:

The board is initialzed and drawn on the standard outputs. It is determined whether
user want to make a first move or not then the game is played. A move for user and
computer is chosen alternately.

A valid move is obtained by finding out valid and empty square by checking whether the
middle square is empty, determing number of empty corners and side squares. It is find
out whether user or computer wins by checking if either symbol has already won. At last
it is asked if a user want to play again or not.

Problem statement 8-queens problem


The n queens puzzle is a puzzle with the following constraints:

Use a chessboard of n columns and n rows.

Place n queens on the chessboard.

No 2 queens can attack each other. Note that a queen can attack any other queen on the same
horizontal, vertical or diagonal line.

The most common n queens puzzle is the 8 queens puzzle, with n = 8.

Functionalities:

● Placing the Queen

​ Queen can be moved in the SW, NW, SE, NE direction and one row up/down
A
keeping the column same. Also the solution should be printed on the board. ​We check
the avaibility of any other queen in the digonal left, digonal right and the vertical positions of
the chess. If no Queen is found in these positions place the Queen there.

● Print minimum moves

​This function finds the output with the minimum moves.

● Print maximum moves

​This function finds the output with the maximum no of moves.

Problem Statement for Tower Of Hanoi’s


The Tower of Hanoi puzzle was invented by the French mathematician Edouard Lucas in 1883. We are
given a tower of eight disks (The picture below just shows four disks for the interest of space), initially
stacked in decreasing size on one of three pegs. The objective is to transfer the entire tower to one of
the other pegs (the third one in the picture below), moving only one disk at a time and never a larger
one onto a smaller.
Let’s call these 8 disks 1, 2, 3, 4, …, to 8, 8 being the largest disk and 1 being the smallest. Let’s call the
pegs A, B, C. Design an algorithm to produce one solution for these 8 disks. Then output the sequence of
disk movement. For instance, the correct movement sequence for 3 disks should be:

move disk 1 from peg A to peg C

move disk 2 from peg A to peg B

move disk 1 from peg C to peg B

move disk 3 from peg A to peg C

move disk 1 from peg B to peg A

move disk 2 from peg B to peg C

move disk 1 from peg A to peg C

Functionalities:

● Tower of Hanoi

Get the number of disks given from the user and​ ​transfer the entire tower to one of the other pegs,
moving only one disk at a time and never a larger one onto a smaller.

You might also like