Experiment 2: To Manipulate Arrays For Solving Various Searching and Sorting Problems in C++
Experiment 2: To Manipulate Arrays For Solving Various Searching and Sorting Problems in C++
OBJECTIVE:
• Creating Array data structure
• Manipulating Array data structure
EQUIPMENT:
• Computer equipped with Microsoft Visual Studio 15 and Office 16
BACKGROUND:
Arrays are among the oldest and most important data structures, and are used by almost every
program. They are also used to implement many other data structures, such as lists and strings.
They effectively exploit the addressing logic of computers. In most modern computers and
many external storage devices, the memory is a one-dimensional array of words, whose indices
are their addresses. Arrays are useful mostly because the element indices can be computed
at run time. Among other things, this feature allows a single iterative statement to process
arbitrarily many elements of an array. For that reason, the elements of an array data structure
are required to have the same size and should use the same data representation.
Figure 1
Lab Manual of ‘Data Structures and Algorithms’
LAB TASKS:
Problem 1:
55 23 14 88 25 88
24 44 48 36 94 14
Problem 2:
Problem 3:
Implement a function that finds common elements in two arrays. You can assume that the sets
are stored using arrays. So, if array1 = {1,2,3,4,5,6,3,2} and array2 is {1,3,5,7}, then array3
should be {1,3,5}. Note array3 should not have any duplicate elements. You have to:
• Display the count of repeating elements (for example 1 repeats 1 time, 3 repeats 2 time)
• Think of all the functions that are required for this problem. Each function should
perform its dedicated task. So plan them out before implementing them.
• Main should only have a set of function calls
Problem 4:
Write a code to take input in 2 dynamic arrays, ask the size of arrays from user. After you have
finished taking input for one dynamic array start for the second. The size of arrays may be
different. Now completely swap the contents of the two dynamic arrays.
Lab Manual of ‘Data Structures and Algorithms’
Problem 5:
Demonstrate
Attempts Attempts Understand
elementary Attempts all
1 partial lab lab tasks the given
skills to lab tasks No
tasks with with concept but
construct with correct attempt
correct incorrect unable to
various data output
output output apply it
structures.
Behaves Completes
Completes
responsibly, the lab task
Completes the lab task Poorly
3 and with help of Does not
the lab task with minor attempts
individually instructor work
on his own help of lab tasks
performs the and students
instructor
lab. around