0% found this document useful (0 votes)
523 views

Lab Manual OF Big Data Analtyics Lab (Bca04207) : BCA General II Year IV Semester Academic Session 2021-22

This document provides information about the Big Data Analytics lab course for the 2021-22 academic year at Poornima University. It includes the lab rules, instructions for students, syllabus, marks scheme, lab plan, objectives, list of experiments, and resources. The experiments cover setting up a single node Hadoop cluster, running basic Hadoop commands, installing Eclipse IDE and executing MapReduce jobs for word counting and joining/aggregating datasets. Students are evaluated based on their lab performance, record, attendance, and discipline through continuous internal evaluations.

Uploaded by

Megha Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
523 views

Lab Manual OF Big Data Analtyics Lab (Bca04207) : BCA General II Year IV Semester Academic Session 2021-22

This document provides information about the Big Data Analytics lab course for the 2021-22 academic year at Poornima University. It includes the lab rules, instructions for students, syllabus, marks scheme, lab plan, objectives, list of experiments, and resources. The experiments cover setting up a single node Hadoop cluster, running basic Hadoop commands, installing Eclipse IDE and executing MapReduce jobs for word counting and joining/aggregating datasets. Students are evaluated based on their lab performance, record, attendance, and discipline through continuous internal evaluations.

Uploaded by

Megha Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 79

Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

LAB MANUAL
OF
BIG DATA ANALTYICS LAB(BCA04207)

BCA General II Year IV Semester


Academic Session
2021-22

TABLE OF CONTENTS
1
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

S.No. Contents Page No.


1 Lab Rules 2-3
2 Instructions 4
3 Syllabus 5
4 Marks Scheme 6
5 Lab Plan 7
6 Lab objective 8
7 List of lab exercises 9
8 Resources 10
9 Experiments 11-47

2
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

LAB RULES
Responsibilities of Users
Users are expected to follow some fairly obvious rules of conduct:

Always:

▪ Enter the lab on time and leave at proper time.


▪ Wait for the previous class to leave before the next class enters.
▪ Keep the bag outside in the respective racks.
▪ Utilize lab hours in the corresponding.
▪ Turn off the machine before leaving the lab unless a member of lab staff has
specifically told you not to do so.
▪ Leave the labs at least as nice as you found them.
▪ If you notice a problem with a piece of equipment (e.g. a computer doesn't
respond) or the room in general (e.g. cooling, heating, lighting) please report it
to lab staff immediately. Do not attempt to fix the problem yourself.

Never:

▪ Don't abuse the equipment.


▪ Do not adjust the heat or air conditioners. If you feel the temperature is not
properly set, inform lab staff; we will attempt to maintain a balance that is
healthy for people and machines.
▪ Do not attempt to reboot a computer. Report problems to lab staff.
3
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

▪ Do not remove or modify any software or file without permission.


▪ Do not remove printers and machines from the network without being explicitly
told to do so by lab staff.
▪ Don't monopolize equipment. If you're going to be away from your machine for
more than 10 or 15 minutes, log out before leaving. This is both for the security
of your account, and to ensure that others are able to use the lab resources while
you are not.
▪ Don’t use internet, internet chat of any kind in your regular lab schedule.
▪ Do not download or upload of MP3, JPG or MPEG files.
▪ No games are allowed in the lab sessions.
▪ No hardware including USB drives can be connected or disconnected in the labs
without prior permission of the lab in-charge.
▪ No food or drink is allowed in the lab or near any of the equipment. Aside from
the fact that it leaves a mess and attracts pests, spilling anything on a keyboard
or other piece of computer equipment could cause permanent, irreparable, and
costly damage. (and in fact has) If you need to eat or drink, take a break and do
so in the canteen.
▪ Don’t bring any external material in the lab, except your lab record, copy and
books.
▪ Don’t bring the mobile phones in the lab. If necessary then keep them in silence
mode.
▪ Please be considerate of those around you, especially in terms of noise level.
While labs are a natural place for conversations of all types, kindly keep the
volume turned down.

If you are having problems or questions, please go to either the faculty, lab in-charge or
the lab supporting staff. They will help you. We need your full support and cooperation
for smooth functioning of the lab.

4
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

INSTRUCTIONS

Before entering in the lab

All the students are supposed to prepare the theory regarding the next experiment.
Students are supposed to bring the practical file and the lab copy.
Previous programs should be written in the practical file.
All the students must follow the instructions, failing which he/she may not be allowed in
the lab.

While working in the lab

Adhere to experimental schedule as instructed by the lab in-charge.


Get the previously executed program signed by the instructor.
Get the output of the current program checked by the instructor in the lab copy.
Each student should work on his/her assigned computer at each turn of the lab.
Take responsibility of valuable accessories.
Concentrate on the assigned practical and do not play games
If anyone caught red handed carrying any equipment of the lab, then he/she will have to
face serious consequences.

5
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Big Data Analytics lab


Code: BCA04207 1.5 Credit [LTP:0-0-3]
manual

Part A
Experiment 1:
Prepare infrastructure and understand objective for software requirement for setting up
single node Hadoop cluster.
 WinSCP
 Putty
 Ubuntu
 VMPlayer
 Hadoop version

Experiment 2:
Create single node Hadoop cluster.
 Installing Ubuntu on VM
 Installing Java
 SSH Configuration
 Core-site.xml Configuration
 Hdfs-site.xml Configuration
 Yarn-site.xml Configuration

Experiment 3:
Testing Single Node cluster, Web UI ports and Exploring different daemons of Hadoop
Cluster.
Experiment 4:
Perform / Execute below sets of Hadoop basic commands:
 appendToFile
 cat
 chgrp
 chmod
 chown
 copyFromLocal
 copyToLocal
 count
 cp

Experiment 5:
Perform / Execute below sets of Hadoop basic commands:
6
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

 du
 dus
 expunge
 get
 getfacl
 getfattr
 getmerge
 ls
 lsr
 mkdir
Part B
Experiment 6:
Perform / Execute below sets of Hadoop basic commands:
 moveFromLocal
 moveToLocal
 mv
 put
 rm
 rmr
 setfacl
 setfattr
 setrep
 stat
 tail
 test
 text
 touchz
Experiment 7:
Install eclipse IDE on single node cluster for executing MapReduce Job and understand the
role of dependent libraries for processing job.
Experiment 8:
Perform a Map Reduce word count job for a given input file by configuring Number of
Reducer 2.
Experiment 9:
Perform a Map Reduce word count job for a given input file by configuring Number of
Reducer 6 and Analyze Experiment 8 and 9.
Experiment 10:
Perform a Map Reduce word count job for a given input file by configuring only Mapper
(No reducer is involved) and Analyze Experiment 8, 9 and 10.
Experiment 11:
Implement one executable Hadoop MapReduce program to perform the inner join of two
tables based on “Student ID” . You can create sample data in below format and can further
7
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

execute this exercise

Experiment 12:
Implement one executable Hadoop MapReduce program to calculate highest temperature
for every given year. You can consider below sample data for executing this job:

MARKS SCHEME

8
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Examination Marks Scheme

A. Practical (Laboratory) Subjects:-

a. Continuous Internal Evaluation (CIE) 40%


- CIE-I (Pr.): Performance, Lab Record, Viva, Attendance and 20%
Discipline
- CIE-II(Pr.): Performance, Lab Record, Viva, Attendance and 20%
Discipline
b. Mid Semester Exam (MSE)– One 20 %
c. End Semester Exam (ESE) – One 40%
TOTAL 100 %

Internal Assessment System

Total Marks – 10

Performance
Attendance Discipline Record Total
& Viva
1 1 5 3 10

9
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

LAB PLAN

Total number of experiment 12


Total number of turns required 12
Number of turns required for

Experiment Number Turns Required Turn No.

Exp. 1 1 1

Exp. 2 1 2

Exp.3 1 3

Exp.4 2 4

Exp.5 1 5

Exp.6 1 6

Exp.7 1 7

Exp.8 2 8

Exp.9 1 9

Exp.10 1 10

Exp.11 1 11

Exp.12 1 12

Distribution of lab hours


Attendance 05 minutes
Explanation of features of language 15 minutes
Explanation of experiment 15 minutes
Performance of experiment 70 minutes
Viva / Quiz / Queries 15 minutes

Total 120 minutes


10
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Lab Objective

• To make the student learn hadoop.


• To teach the student to create Hadoop clusters.
• To introduce the student to various concepts of Big Data Analytics like MapReduce.

Big Data is high-volume, high velocity, and variety information assets that demand cost-
effective,innovative forms of information processing for enhanced insight and decision
making.

So to make students industry ready learning of Big Data Analtyics is necessary.

11
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

List of Lab Exercises

Sr. No. Name of experiment


Cycle-1
1. Briefly Understand Big Data,Underlying Technologies and Tools Used in Big Data
Analytics.
2. Apply Weka Tool and Analyze Apriori Algorithm.
3. Calculate Mean,Median ,Mode,Standard Deviation, Percentile, Data Distribution
and Normal Data Distribution of an array of integer data.
4.
5.
6.
Cycle-2
7.
8.
9.
10.
11.
12.

12
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Resources for all the labs

Hardware :
1.Computer &
2.Peripheral devices

Software:
1. Python,Anaconda,Pycharm,Visual Studio Code, Hadoop,Linux

Text Books:
1. Big Data Analytics by Dasivam R. Thirumahal by Oxford University Press.

Reference Books:
1. Big Data Analytics with Microsoft HD Insight,

Reference Websites:
1. www.tutorialpoint.com

2. www.w3school.com

13
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiments

14
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:1
Name of Experiment: Briefly Understand Big Data,Underlying Technologies and Tools
Used in Big Data Analytics.

Aim: To learn about Big Data.

Output:

The student knows the basics of Big Data.


Viva question :

1. What is Big Data?


2. Explain the applications of Big Data.
3. What are the types of Big Data.
4. Write the characteristics of Big Data.

Experiment No2
Name of Experiment: Write a program to apply Weka Tool and analyze Apriori
Algorithm.

Aim: To find out the association rules of Apriori Algorithm.


15
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Output:

The Association rules for Apriori Algorithm are computed,

Viva question :

1. What is Apriori Algorithm?


2. Explain minimum support and minimum confidence.
3. How do you obtain the association rules finally.

16
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:3
Name of Experiment: Calculate Mean,Median ,Mode,Standard Deviation, Percentile, Data
Distribution and Normal Data Distribution of an array of integer data.

Aim: To find out the values of various paramters.


Theory:
Output:

Viva question :

1. H
2. W
3. W
4. H

17
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:2.B

Name of Experiment: Use pointers to concatenate two strings.

Aim: To concatenate two string.

Algorithm: (Step wise)


Step1: Input two string from user. Store it in some variable say str1 and str2. Here we need to
concatenate str2 to str1

Step2: Find length of str1 and store in some variable say i = length_of_str;.

Step3: Run a loop from 0 till end of str2 and copy each character to str1 from the ith index.

Flowchart:

18
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory: In concatenate (combine) operation of two string, contents of two string are
combined in one string.

Basic string concatenation


The algorithm is based on below facts.

In order to merge two strings, first we have to copy all the characters of first string into new
string until NULL character is encountered in the first string. After copying all the characters
of first string into new string we have to copy all the characters of second string into new
string until NULL character is encountered in the second string.

Output:

19
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Viva question :

1. What is terminating character of a string?


2. How to count length of a string?
3. What happen if we concatenate NULL with a string?
4. How to insert space between two string?

20
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:3.A

Name of Experiment: Use pointers to copy a string.

Aim: To Copy a given string using pointer to another string.

Algorithm: (Step wise)


Step 1: Start
Step 2: Declare variable
Step 3: Take string input
Step 4: Copy base address to pointer variable
Step 5: Read and print string stored from address
Step 6: End

Flowchart:

21
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory: In copy a string we find at which position we have to copy a given string.

Basic string copy using pointer


The algorithm is based on below facts.

Output:

22
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Viva Question:

1) What is string?

2) Which command is used to combine the two strings?

3) Which command is used to copy the strings?

23
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:3.B

Name of Experiment: Use a recursive function for the towers of Hanoi with three
discs.

Aim: To design tower of Hanoi using recursive function.

Algorithm: (Step wise)


Step 1: start
Step 2: initialize the source=a, intermediate=c, destination = d
Step 3: read n
Step 4: call the sub program Hanoi recursion (n value,a ,b, c)
Step 5: stop

Sub program:
Step 1: if n== 1 call the sub program Hanoi recursion (num-1, a, c, b)
Step 2: print the output from a to b
Step 3: call the sub program Hanoi recursion(num-1, b, c, a) Step
4: return to main program

Flowchart:

24
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Sub-Process of Tower of Hanoi:

25
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory: Towers of Hanoi problem means we have three towers.

The algorithm is based on below facts.

Here source, intermediate and destination are the three towers. We have to transfer all the
disks from source to destination towers. Here the restriction is not to place a big disk on
smaller one. For this we use intermediate tower. Finally the arrangements in the destination
tower must be as same as the disks in the source tower at first.
Towers of Hanoi problem means we have three towers

Source intermediate destination

26
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Output:

Input No of Disk : 2
Output : Disk 1 moved from A to B
Disk 2 moved from A to C
Disk 1 moved from B to C

Input No of Disk: 3
Output : Disk 1 moved from A to C
Disk 2 moved from A to B
Disk 1 moved from C to B
Disk 3 moved from A to C
Disk 1 moved from B to A
Disk 2 moved from B to C
Disk 1 moved from A to C
Viva Question:

1) What is purpose of towers of Hanoi?


2) What is recursion?
3)

27
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:4.A

Name of Experiment: Insert an integer into a given position in an array.

Aim: To put a new integer value in an array at a specified location.

Algorithm: (Step wise)

Let Array be a linear unordered array of MAX elements. et LA be a Linear Array


(unordered) with N elements and K is a positive integer such that K<=N. Following is the
algorithm where ITEM is inserted into the Kth position of LA −

Step1: Start

Step 2: Set J = N

Step 3: Set N = N+1

Step 4: Repeat steps 5 and 6 while J >= K

Step 5: Set LA[J+1] = LA[J]

Step 6: Set J = J-1

Step 7: Set LA[K] = ITEM

Step 8: Stop

Flowchart:

28
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

Output:

29
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Viva Question:

1) How to pass an array by value in C?


2) Write pseudo code to print Sum of even and odd elements in an array.

30
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:4.B

Name of Experiment: Deleting an integer from an array.

Aim: To remove or delete an integer value in an array at a specified location.

Algorithm: (Step wise)

Consider LA is a linear array with N elements and K is a positive integer such that K<=N.
Following is the algorithm to delete an element available at the Kth position of LA

Step 1. Start

Step 2. Set J = K

Step 3. Repeat steps 4 and 5 while J < N

Step 4. Set LA[J] = LA[J + 1]

Step 5. Set J = J+1

Step 6. Set N = N-1

Step 7. Stop

Flowchart:

31
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

Output:

The original array elements are :


LA[0] = 1
32
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
The array elements after deletion :
LA[0] = 1
LA[1] = 3
LA[2] = 7
LA[3] = 8

Viva Question:

1) How to pass an array by value in C?


2) Write pseudo code to print Sum of even and odd elements in an array.

33
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:5

Name of Experiment: Write a program to create a linked list and to display it.

Aim: To create a linked list and display it’s elements.

Algorithm: (Step wise)

Step 1: Start

Step 2: Declare a structure named linked-list

Step 3: Declare the pointers, start, and, new of linked-list type

Step 4: Print main menu

Step 5: Read choice provided by user

Step 6: If(choice==1 (create linked list))

6.1 Assign new=malloc(size of (node))

6.2 Take data from user and store it in new->data

6.3 Put NULL in new->next

6.4 Connect this new node at the end of the linked list

Step 7: If(choice==2(for display))

7.1: if start = NULL, print “Linked list is EMPTY”

7.2.: Assign ptr=start

7.3: Repeat step 7.4 and 7.5 until ptr = NULL

34
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

7.4: print ptr->data

7.5 set ptr = ptr->next

Step 8: If choice==3

8.1 Call exit system call or api for Exit()

Step 9: End

Flowchart:

35
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

In this procedure we have to create a single linked list, and display it’s elements. We first
create data structure for linked list which is node of a linked list. A node contain data and
pointer part. One node is connected with another node by pointer part.

Output:

Viva Question:

36
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

1) List out the memory allocation functions ?


Ans: malloc(), calloc(),free(), realloc() etc..,
2) Define linked list ?
Ans: Linked list is list whose order is given by links from one item to the next
3) List out the advantages of linked list ?
Ans:
i). Dyanamic data structure
ii). no waste memory space
iii).flexibility

37
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:6 A

Name of Experiment: Write a program to sort N numbers using insertion sort.

Aim: To create an unsorted array and sort it using insertion sort.

Algorithm: (Step wise)

Insertion Sort:

Step 1. start

Step 2. for i= 1 to n increment in steps of 1

begin

assign k[i] to temp

Step 3. For j=i-1 down to j>=0 and temp<k[j]

begin

assign k[j] to k[j+1]

end inner for loop

Step 4. assign temp to k[j+1]

end for loop

Step 5. Stop

38
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Flowchart:

39
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

40
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Insertion sort is similar to playing cards. To sort the cards in yourhand you extrat a card shift
the remaining cards and then insert the extracted card in its correct place. The efficiency of
insertion sort is O(n2).

Output:

enter the range of array:5


enter elements into array:
5
4
3
2
1
the sorted order is: 1 2 3 4 5

enter the range of array:6


enter elements into array:
23
12
89
45
67
34
the sorted order is: 12 23 34 45 67 89

Viva Question:

1) Define insertion sort ?


Ans: Insertion sort is similar to playing cards. To sort the cards in yourhand you
extrat a card shift the remaining cards and then insert the extracted card in its correct
place.

2) Efficiency of the insertion sort ?


Ans: The efficiency of insertion sort is O(n2).

41
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No.:6 B

Name of Experiment: Write a program to sort N numbers using selection sort.

Aim: To create an unsorted array and sort it using selection sort.

Algorithm: (Step wise)

Selection Sort:

1) Start
2) Initiliaze the variables I,j,temp and arr[]
3) Read the loop and check the condition. If the condition is true
print the array elements and increment the I value.
Else goto step 4
4) Read the loop and check the condition. If the condition true then goto next loop.
5) Read the loop and check the condition. If the condition true then goto if condition
6) If the condition if(arr[i]>arr[j]) is true then do the following steps
i) temp=arr[i]
ii) arr[i]=arr[j]
iii) arr[j]=temp
7) increment the j value
8) perform the loop operation for the displaying the sorted elements.
9) print the sorted elements
10) stop

42
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Flowchart:

43
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

This is the simplest method of sorting. In this method, to sort the data in ascending order, the
0th element is compared with all other elements. If the 0th element is found to be greater than
the compared element then they are interchanged.

Output:

Section sort

Array before sorting:


25 17 31 13 2

Array after sorting:

2 13 17 25 31

section sort
Array before sort
25 31 30 12 1

Array after sort


1 12 25 30 31

Viva Question:

1) The complexity of the section sort algorithm ?


Ans: O(n2)
2) Drawback of the binary tree ?
Ans: Additional space is required for building the tree
3) The complexity of the heap sort algorithm ?
Ans: O(n og n)

44
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

PART-B
Experiment No. :1

Name of Experiment: Inserting a node into a singly linked list.

Aim: To create a singly linked list and insert a new item in the list.

Algorithm: (Step wise)

Step 1: Start

Step 2: Declare a structure named linked-list

Step 3: Declare the pointers next, start, temp and ptr

Step 4: Print main menu

Step 5: Read choice

Step 6: Switch(choice)

Step 7: If(choice==1)

7.1 Assign temp=malloc(size of (node))

7.2 Read the element data from user and store in ptr->data

7.3 Assign ptr->next = NULL

7.4 Read the choice where to insert

7.5 Switch(choice)

7.5.1: If choice==1

45
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

7.5.2: Call the function IBegin()

7.5.3: If choice==2

7.5.4: Call the function Iend()

7.4.5: If choice==3

7.4.6: Call the function After_a_node()

Step 8: If choice==2

10.1 Exit()

Step 11: End

Flowchart:

46
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

In this program we have to create a single linked list, insert the elements into that list at first
Position, last position, and after a specified data or information.

Output:

***** OUTPUT *****

**** MENU(INSERT A NODE) ****

1. Insert at first location


2. Insert at last location
3. Insert after a specified node
4. Display
5. Exit

enter the choice:1


enter the item to be inserted:11

enter the choice:1


enter the item to be inserted:22

enter the choice:2


enter the item to be inserted:33

enter the choice:4

22->11->33->NULL

enter the choice:3


enter the item to be inserted:44
enter the data item after which you want to insert :11

enter the choice:4

47
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

22->11->44->33->NULL

enter the choice:3


enter the item to be inserted:55
enter the data item after which you want to insert :45

ITEM 45 is not present in the list.

enter the choice:4

22->11->44->33->NULL

Viva Question:

1) List out the memory allocation functions?


Ans: malloc(), calloc(),free(), realloc() etc..,

2) Define linked list ?


Ans: Linked list is list whose order is given by links from one item to the next

3) List out the advantages of linked list ?


Ans:
i) Dyanamic data structure
ii) no waste memory space
iii) flexibility

48
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No. :2

Name of Experiment: Deleting a node from a singly linked list.

Aim: Deleting a node from a singly linked list from various position such as first, last
and after a specified position.

Algorithm: (Step wise)

Step 1: Start

Step 2: Declare a structure named linked-list

Step 3: Declare the pointers start, temp and ptr

Step 4: Print main menu

Step 5: Read choice

Step 6: Switch(choice)

Step 7: If(choice==2)

7.1: Read the position to delete

7.2: Switch(choice)

7.2.1: If choice==1

7.2.2: Call the function DBegin()

7.2.3: If choice==2

7.2.4: Call the function Dend()

49
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

7.2.5: If choice==3

7.2.6: Call the function Dmiddle()

Step 8: If choice==2

8.1 Exit()

Step 11: End

Flowchart:

50
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

In this program we have to create a single linked list, insert the elements into that list at first
Position, last position, and after a specified data or information.

Output:

***** OUTPUT *****

**** MENU(INSERT A NODE) ****


51
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

1. Delete at first Node


2. Delete at last Node
3. Delete after a specified node
4. Display
5. Exit

enter the choice:4

11->22->33->44->55->66->77->NULL

Enter which node you want to delete: 1


First Node deleted successfully.
enter the choice:4

22->33->44->55->66->77->NULL

Enter which node you want to delete: 2


Last Node deleted successfully.
enter the choice:4

22->33->44->55->66->NULL

Enter which node you want to delete: 3


Enter Data value = 33
Node after 33 is deleted successfully.

enter the choice:4


22->33->55->66->NULL
Enter which node you want to delete: 3
Enter Data value = 45
Data 45 is not available in linked list.

enter the choice:4


22->33->55->66->NULL

Viva Question:
52
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

1) List out the memory allocation functions?


Ans: malloc(), calloc(),free(), realloc() etc..,

2) Define linked list ?


Ans: Linked list is list whose order is given by links from one item to the next

3) List out the advantages of linked list ?


Ans:
i) Dyanamic data structure
ii) no waste memory space
iii) flexibility

53
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No. :3

Name of Experiment: Pointer implementation of stacks.

Aim: To create a stack using indirect access or pointer and perform the basic
operation.

Algorithm: (Step wise)


Step 1: Start
Step 2: Declare the structure for the stack pointers.
Step 3: Define the push function
Step 4: Define the pop function
Step 5: Define the display function
Step 6: Read the choice
Step 7: if choice = push
Create a cell for the TOP cell in the stack. Place the date in the TOP cell
Place the TOP pointer to the new cell
Step 8: if choice=pop
Check if empty stack. If so, print stack is empty. Otherwise, remove the TOP cell.
Step 9: if choice=display
Display all the elements in the Stack.
Step 10: Stop

54
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Flowchart:

55
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

56
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

In this algorithm we have to implement the stack operation by using the pointers. Here they
stack operation are push and pop. Push operation is used to insert the elements into a stack
and pop operation is used to remove the elements in to a stack.

Output:

======================================
MENU
======================================
[1] Using Push Function
[2] Using Pop Function
57
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

[3] Elements present in Stack


[4] Exit

Enter your choice: 1 Element to be pushed:23


======================================
MENU
======================================
[1] Using Push Function
[2] Using Pop Function
[3] Elements present in Stack
[4] Exit

Enter your choice: 3

Elements present in the stack are: 23


======================================
MENU
======================================
[1] Using Push Function
[2] Using Pop Function
[3] Elements present in Stack
[4] Exit

Enter your choice: 2 Element to be popped: 23

======================================
MENU
======================================
[1] Using Push Function
[2] Using Pop Function
[3] Elements present in Stack
[4] Exit

Enter your choice: 4 Exit the program

Viva Question:

1) Define Stack ?
58
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Ans: A stack is a linear data structure in which a data item is inserted and deleted at one
end
2) Define data structure ?
Ans: A data structure is a collection of organized data that are related to each other

3) What are the various operation performed on the stack ?


Ans: push(), pop()

59
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No. :4

Name of Experiment: Pointer implementation of queues.

Aim: To create a queue using indirect operator and perform operations.

Algorithm: (Step wise)

Step 1: Start

Step 2: define structure for queue

Step 3: read choice

Step 4: if choice = insert

i) read the element


ii) create a data structure
iii) if empty queue then front of queue pinter points to newly created data
structure
iv) otherwise end of the queue points to newly created data structure

Step 5: if choice= remove

i) check if queue is empty . if so, print queue is empty


ii) otherwise read the element pointed by front of the queue temp pointer points
to front of queue
iii) front of queue points to next element
iv) free the element pointed by temp pointer
v) return the element
vi) print the element

Step 6: if choice = display

i) check of empty queue if so, print queue empty


ii) otherwise print the elements from front of the queue until the end of the queue
60
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Step 7: if choice=exits stop

Flowchart:

61
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

In this program we have to implement the Queue operation by using the pointers. Here they
Queue operation are push and pop. Push operation is used to insert the elements into a Queue
and pop operation is used to remove the elements in to a Queue.

Output:

****IMPLEMENTATION OF QUEUE USING POINTERS****


============================================== MENU
==============================================
[1] To insert an element
[2] To remove an element
[3] To display all the elements

[4] Exit

Enter your choice:1 Element to be inserted:23

62
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

****IMPLEMENTATION OF QUEUE USING POINTERS****


============================================== MENU
==============================================
[1] To insert an element
[2] To remove an element
[3] To display all the elements
[4] Exit

Enter your choice:


3

Elements present in Queue are:


23

****IMPLEMENTATION OF QUEUE USING POINTERS****


============================================== MENU
==============================================
[1] To insert an element
[2] To remove an element
[3] To display all the elements
[4] Exit
Enter your choice:2
23 is removed from the queue
****IMPLEMENTATION OF QUEUE USING POINTERS****
============================================== MENU
==============================================
[1] To insert an element
[2] To remove an element
[3] To display all the elements
[4] Exit

Enter your choice:4 Exit

Viva Question:

1) Define queue?
Ans: A queue is a linear, sequential list of that are accessed in the oeder first in first
out(FIFO).
63
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

2) Define circular queues ?


Ans: A queue can also be circular in which case, it is called as a circular queue
3) What are the various stack oriented notations ?
Ans: i) infix ii) prefix iii) postfix

64
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No. :5

Name of Experiment: Creating a binary search tree and traversing it using in order,
preorder and post order.

Aim: To create a tree and perform traversing operation.


Algorithm: (Step wise)

Step 1: Start

Step 2: Define a structure BSTree

Step 3: Type define struct BSTree as node

Step 4: While(tree), begin

Step 5: Print MENU

Step 6: Write your choice

Step 7: If choice=1

Step 8: Enter your no of nodes

Step 9:Read nodes n

Step 10: for i=1 to n in steps of 1 do Step

11: Print enter item

Step 12: Read item

Step 13: Root =call create (root, item).end for

Step 14: if choice=2

65
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Step15: Read element to be deleated

Step 16: Call delete(root, item) end for

Step 17: If choice=3

Step 18: Call preorder(root)

Step 19: Call postorder(root)

Step 20: Call inorder(root)

Step 21: Break, end of switch

Step 22: Stop

For insert function

Step 1: Start

Step 2: If t= null

Step 3: Allocate memory to temp

Step 4: Temp->data =item

Step 5: Temp-> lc=null

Step 6: Temp->rc=null

Step 7: return t to main and end

Step 8: If item< (l->data)

Step 9: T->lc=call insert(e->lc, t)

66
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Step 10: T->rc=call isert(e->lc,t)

Step 11:Return t

Step 12: Stop

For DELETION function

Step 1: Start

Step 2: x=d

Step 3: while x!=null

Step 4: If x->data =t

Strep 5:Break

Step 6: Parent =x

Step 7: if t<x->data

Step 8: t=t->lc

Step 9: t=l->rc

Step 10: If x->lc!=null &&x->rc!=null

Step11: parent =x

Step12: If parent==null

Step 13: parent->lc==null

Step 14: parent->rc==null

Step 15: If p->lc=x->rc

Step 16: If p->rc=x->rc

67
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Step 17: While insert->lc=null

Step 18: Insert=insert->la

Step 19:x->data=insert->data

Step 20:x=insert

Step 21: Return d

Step 22: Stop

For INORDER function

Step 1: Start

Step 2: If t!=null

Step 3: Call inorder(t->lc)

Step 4: Write t->data

Step 5: Call inorder(t->rc)

Step 6: Stop

For POSTORDER function

Step 1: Start

Step 2: If t!=null

Step 3: Call postorder(t->lc)

Step 4: Call postorder(t->rc)

Step 5: Write data

Step 6: Stop

68
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

For PREORDER function

Step 1: Start

Step 2: If t!=null

Step 3: Write data

Step 4: Call postorder(t->lc)

Step 5: Call postorder(t->rc)

Step 6: Stop

Flowchart:

69
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

70
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

71
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

The data structure tree is of non linear type. Binary tree is bit special. The proparty of a
binary tree is the value at the root must be grater than the left node and less than the right
node. The binary tree consist of almost two childrens. Tree is a recursive data structure and
recursive programming techniques are popularly used in trees. A tree can can be traversed in
three major ways
i) Inorder traversal: here left child is visited first followed by root and finally by right
child.
ii) Preorder traversal: Here root is visitedfirst follwed by left child and finally by right
child.
iii) Postorder traversal: Here left child is visited first followed by right child finally by
the root.

Output:

Enter your choice


1. Insert 2.Delete 3.Traversal
Enter the element 92

Enter your choice


1. Insert 2.Delete 3. Traversal
Enter the element 26

Enter your choice


1.Insert 2.Delete 3.Traversal
Enter the element 12

Enter your choice


1.Insert 2.Delete 3.Traversal
Enter the element 123

Enter your choice


1.Insert 2.Delete 3.Traversal
Enter the element 135

Enter your choice


72
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

1.Insert 2.Delete 3.Traversal


Enter the element 128
Enter your choice
1.Insert 2.Delete 3.Traversal 3

InorderSequence: 12 26 92 123 128 135

Preorder sequence:92 26 12 123 135 128

Postorder sequence: 12 26 128 135 12 92

Viva Question:

1) Define Binary tree ?


Ans: Binary tree is a bit special, because whan they are in the sorted form, they facilitate
quick search, insertion, and deletion.
2) How many ways a tree can be traversed ?
Ans: In three ways. They are i) In-order ii) pre-order iii) post-order
3) define graph ?
Ans: A graph is a set of nodes(vertices) and a set of arcs(edges). A graph is connected if
there is a path between any two nodes of the graph.

73
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Experiment No. :6

Name of Experiment: Sort N numbers using merge sort.

Aim: To create an unsorted array and sort it using selection sort.

Algorithm: (Step wise)

Step1: Start

Step2: declare the merge sort function

Step3: Declare the array and their size and initailaze the j=0

Step4: read the array elements and then sort these elements.

Step5: read the array elements before the merge sort and then display the elements.

Step6: call the merge sort function

Step7: display the array elements after merge sort by using the following stament.

for( j=0;j<Max_ary;j++)

Step8: Stop

Subprogram

Step1:initialize the array

excuting[MAX_ARY] and j=0,mid=0,mrg1=0,mrg2=0,size=start-end+1

Step2: check the condition if(end==start) then return

74
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Step3: calculate the mid value

Mid=(end+start)/2

Step4: call themerge_sort(x,end,mid)

Step5:merge_sort(x,mid+1,start)

Step6: performing the looping operation

For(j=0;j<SIZE;j++) then its true Executing[j]=x[end+1]

Mrg1=0;

Step7: calculate the mrg2=mid-end+1

Step8: performing the looping operation

For(j=0;j<SIZE;j++) then its true then goto step9

Step9: check the condition

i) if(mrg2<=start-end) is true goto ii). If not goto Step12.

ii) If(mrg1<=mid-end) is true goto iii). If not goto step11

iii) If(executing[mrg1]>executing[mrg2]) is true then follows. If not goto step10.

X[j+end]= executing[mrg2++]

Step10: x[j+end]=executing[mrg1++]. If not goto Step11

Step11: x[j+end]= executing[mrg2++]

Step12: x[j+end]=executing[mrg1++]

Step13: return to main program

75
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Flowchart:

76
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

77
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

78
Lab Manual – BCA04207 –Big Data Analytics Lab Poornima University, Academic Year 2021-22

Theory:

The merge sort splits the list to be sorted into two equal halves, and places them in separate
arrays. Each array is recursively sorted, and then merged back together to form the final
sorted list. Like most recursive sorts, the merge sort has an algorithmic complexity of O(n
log n).
Output:

Section sort

Enter the elements to be sorted: 8 2 3 4 1 5 7 6 9 0


Before : 8 2 3 4 1 5 7 6 9 0
After Merge Sort : 0 1 2 3 4 5 6 7 8 9

Enter the elements to be sorted: 7 6 5 4 8 4 3 2 1 3


Before : 7 6 5 4 8 4 3 2 1 3
After Merge Sort : 1 2 3 3 4 4 5 6 7 8

Viva Question:

1) Define merge sort?

Ans: The merge sort splits the list to be sorted into two equal halves, and
places them in separate arrays. Each array is recursively sorted, and then
merged back together to form the final sorted list.

2) Efficiency of merge sort?


Ans: O(n log n).

79

You might also like