Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A. Find
- Given a list of strings L (hardcoded) and a string s (user input), find whether s is in L and report to the screen.
- For example, if L = ['python', 'cpp', 'java'], if user inputs 'c', you should print "Not in the list."
- Hint: Similar to prime checking (Use flag variable).
- # B. Bubble Sort
- Given a list of numbers L, sort L in increasing order and print L.
- For example, if L = [5, 2, 4, 1, 8, 3], you should output [1, 2, 3, 4, 5, 8].
- One popular algorithm for sorting is called "Bubble Sort."
- - You make n-1 "passes" through the array.
- - In each pass, you look at each adjacent pair of numbers. If the left number is greater than the right number, swap.
- See the following video for algorithm visualization (Loud sound warning):
- https://www.youtube.com/watch?v=Cq7SMsQBEUw
- # C. Intersection
- Given two lists L1 and L2, generate a list L3 which is the intersection of L1 and L2. You may assume L1 and L2 each has no duplicate elements. Any ordering in L3 is fine. (So, L1, L2, L3 act like sets.)
- For example, if L1 = [3,2,7,6,8] and L2=[1,2,3,4,5], one possible output is [3,2].
- Hint: You will need to use problem A as a subroutine in your program.
- # D. Statistics
- Given a list of numbers L, output the minimum, maximum, mean, median, mode.
- If you can only do min/max/mean, that's fine. Median and mode require some insights.
Add Comment
Please, Sign In to add comment