You are on page 1of 7

Activity No.

4
Linked Lists
Course Code BCS 120 Program:
Course Title Fundamentals of Programming Date Performed:
and Data Structures
Section: Date Submitted:
Name: Instructor:
1. Objective:
The goal of this laboratory activity is to gain experience with stack and queue data structures
and their applications.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Write a short program inserting elements at the front, back, and middle of the linked list.
2.2 Execute programs to modify and display contents of a linked list
2.3 Examine the application of linked lists in queues and staacks in C++
3. Resources:
Computer with 32-bit Operating System
Dev C++

4. Procedure:
Programming Exercise A.
Create a program that allows the user to enter different integers. If the user enters a number greater
than or equal to 10, the number gets added to the end of the list. If a number less than 10 is entered,
it goes to the start of the list.
If 999 is entered, the number is placed after the second node and the program displays the content of
the linked list.

Ex. Linked List Content


11 11
12 11 12
1 1 11 12
2 2 1 11 12
999 2 1 999 11 12 (program then displays the content)

Output:

Linked List contains2 1 999 11 12


Programming Exercise B.
Create two programs that simulates a stack and queue. Each program must have the user defined
functions push, pop, peek, and printContent.
DO NOT IMPORT STACK OR QUEUE HEADERS (#include <stack/queue>)

For Stack:
>> PUSH
>> 3
>> PUSH2
>> PRINT CONTENT
>> 2 3
>> POP
>> PUSH
>> 5
>> POP
>> PEEK
>> 3

For Queue:
>> PUSH
>> 3
>> PUSH
>> 2
>> PRINT CONTENT
>> 3 2
>> POP
>> PUSH
>> 5
>> POP
>> PEEK
>> 5

BONUS:

Create a program to print out a half pyramid using letters from the alphabet. The user must
enter the size of the pyramid from 1 to 10.

A
BB
CCC
DDDD
EEEEE
5. DATA ANALYSIS:
1. Create a pseudo code to demonstrate how to search for a specific element in a given linked
list and delete that element.
7. DISCUSSION
8. CONCLUSION
9. Assessment (Rubric for Laboratory Performance)

You might also like