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

CSC 221 Exam Study Guide (1)

The CSC 221 Exam Study Guide covers key concepts in programming, including arrays, expressions, stacks, queues, and sorting algorithms. It provides examples and applications for each topic, such as using arrays for data storage and implementing stacks for LIFO operations. The guide emphasizes the importance of practice and memorization of key formulas and past questions for exam preparation.

Uploaded by

qudus4060
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)
39 views

CSC 221 Exam Study Guide (1)

The CSC 221 Exam Study Guide covers key concepts in programming, including arrays, expressions, stacks, queues, and sorting algorithms. It provides examples and applications for each topic, such as using arrays for data storage and implementing stacks for LIFO operations. The guide emphasizes the importance of practice and memorization of key formulas and past questions for exam preparation.

Uploaded by

qudus4060
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/ 4

CSC 221 Exam Study Guide

1. APPLICATION OF ARRAYS

Arrays store elements of the same type in contiguous memory locations.

Applications include:

- Storing lists of data (e.g., student records, game scores)

- Matrix operations (e.g., image processing)

- Implementing other data structures (e.g., stacks, queues)

- Hash tables (used in database indexing)

Example:

int numbers[5] = {10, 20, 30, 40, 50};

2. HOW TO WRITE EXPRESSIONS

Expressions define computations in programming. There are three common notations:

- Postfix (Reverse Polish Notation - RPN): Operators after operands.

Example: 3 4 + instead of 3 + 4

- Prefix (Polish Notation): Operators before operands.

Example: + 3 4 instead of 3 + 4

- Infix (Standard Notation): Operators between operands.

Example: 3 + 4
Conversion from Infix to Postfix:

Example: (A + B) * C -> A B + C *

3. EXPRESSIONS

Expressions are combinations of operands (values, variables) and operators (+, -, *, /).

Example:

int x = (a + b) * c;

4. SPARSE ARRAYS

A sparse array stores only non-zero values and their indices.

Example:

(0,2,3) (1,4,5) (2,0,6) (3,1,7) (4,3,8)

5. REVIEW TEST QUESTIONS

Practice converting expressions, implementing stacks, and understanding circular queues.

6. STACK

A stack is a Last-In, First-Out (LIFO) data structure.

Operations:

- Push: Add an element.

- Pop: Remove the top element.

- Peek: View the top element.

Example in Python:
stack = []

stack.append(10)

stack.append(20)

print(stack.pop()) # Removes 20

7. STACK OPERATIONS

Used in:

- Reversing a string

- Undo feature in text editors

- Expression evaluation

- Backtracking algorithms

8. CIRCULAR QUEUE

A queue that wraps around when reaching the end.

9. SORTING ALGORITHMS

- Bubble Sort (Simple but slow)

- Insertion Sort (Efficient for small datasets)

- Selection Sort (Good for limited swaps)

- Merge Sort (Efficient for large datasets)

- Quick Sort (Fastest in many cases)

Example (Bubble Sort in Python):

def bubble_sort(arr):

for i in range(len(arr)):

for j in range(0, len(arr)-i-1):

if arr[j] > arr[j+1]:


arr[j], arr[j+1] = arr[j+1], arr[j]

arr = [5, 3, 8, 1]

bubble_sort(arr)

print(arr) # Output: [1, 3, 5, 8]

FINAL TIPS

- Practice coding stacks, queues, and sorting.

- Memorize key formulas (e.g., stack operations, sorting complexities).

- Solve past questions (especially conversions of expressions).

You might also like