Data Structures:

Goal: Given a problem, how do we solve it efficiently?

What we want to do as computer scientists is automate the process of solving specific problems.

Problem Solving Steps

1.) Generate an initial naive solution. Do this to validate your correctness.

2.) Refine your initial solution(if possible).

1.) Efficiency (Time and Space)

2.) Algorithm Design (Number of Steps)

3.) Data Structure Design (Organization of Data)

Exercises

Exercise 1: How would you find the maximum number from a given list of integers that are arranged in a random order(Example: {5,3,2,5,7,12,0} )

Exercise 2: Find the max and min of n integers.

Hints:

Questions to ask yourself: How many comparisons do you have to make to find just the max or just the min?

Can we think of the max and min as “defeating” the other numbers in a tournament?

Can you avoid checking if certain numbers are a min or max more than once? (How can we minimize the set of winners or losers in our set when checking if they “win” or “lose” as a min or max.

Exercise 3: Find the max and second max of n integers.