Data Structures and Algorithms Lab7SectionA
Data Structures and Algorithms Lab7SectionA
Note : You have to solve issues of syntax error, compilation error, linker error by your own.
If the TA is unable to solve this issue then it is not the TA’s problem.
Task 1: (40)
function which given a list that is sorted in increasing order, and a single node, inserts the node
3. void insertSort()
Given a list, split it into two sublists. One for the front half, and one for the back half. If the
number of elements is odd, the extra element should go in the front list. So FrontBackSplit() on
the list {2, 3, 5, 7, 11} should yield the two lists {2, 3, 5} and {7, 11}. Getting this right for all the
cases is harder than it looks. You should check your solution against a few cases (length = 2,
length = 3, length=4) to make sure that the list gets split correctly near the shortlist boundary
conditions. If it works right for length=4, it probably works right for length=1000. You will
probably need special case code to deal with the (length <2) cases.
5. alternatingSplits(Dll<T> &source, Dll<T>& head1, Dll<T>& head2)
Write a function alternatingSplit() that takes one list and divides up its nodes to make two
smaller lists. The sublists should be made from alternating elements in the original list. So if the
original list is {a, b, a, b, a}, then one sublist should be {a, a, a} and the other should be {b, b}.
Task 2: (10)
Implement a function bool delBinarySequence(); of above class, which will take a binary
string(e.g. 101000, 11, etc.) from user and delete all nodes of list which correspond to 1 in the
input string. Please note, deletion can only take place upto the end of list OR end of input
string.
Sample Output:
ForwardDirection:
Backward Direction: 5.2 => 8.11 => 9.64 => 1.005=>7.48=>4.16 =>