|
CS256 - Principles of Structured Design
Fall 2021
|
Displaying ./code/cs256su21code/quiz5notes.txt
Quiz 5 Notes
Date: July 29
Due: July 30 @11:59PM
10 points
On Blackboard
Open book, note, internet
Questions to expect
1. Maybe one question on structs (straight from the reading in Lessons/Tutorialspoint)
Look in C Lesson 7- Structured Data in the Lessons Link
*** For 2, 3, 4, 5, Look at jul14, jul15 and also jul19 ***
2. Bitwise operators: (jul14)
Know all of these, (their symbols, and how to yield a 1 bit from that operation):
AND (&) - both cooresponding bits have to be 1
OR (|) - at least one of the cooresponding bits has to be a 1
XOR (^) - the corresponding bits cannot be the same
NOT (~) - the bits flip (0's become 1's, and 1's become 0's
left shift (<<) - the bits shift to the left a specified number of times
0 bits are added to the right end, leftmost bit will drop out
right shift (>>) - the bits shift to the right a specified number of times
0 bits are added to the left end, rightmost bit drops out
3. Given two bit strings, do a specified bitwise operation
4. Looking at a bitwise operation that was done, can you tell which one was done to get the answer?
5. Setting, clearing and toggling a bit. (jul15 directory)
*** 6 and 7 will be about sorts, drawing from the jul19, jul20 and jul21 directories of in-class code ***
6. A question or two about sorts in general.
-Might ask a question about Big O, since we briefly touched upon that, something along the lines of what
it means.(In simple terms, Big O times refer to how a change in the size of the input affects the runtime)
7. Given a list of numbers, what would that list look like after one passthrough of bubble sort?
Recall that in bubble sort, we look at two adjacent arrays and swap them if they're out of order.
Ex: arr[] = {5, 1, 3, 7, 9, 4, 6, 2, 8} <--start
{1, 5, 3, 7, 9, 4, 6, 2 ,8} <- look at index 0,1, they're out of order, so swap
{1, 3, 5, 7, 9, 4, 6, 2, 8} <- index 1, 2 are out of order, so swap
- index 2,3 are in order, so don't swap
- index 3,4 are in order, so don't swap
{1, 3, 5, 7, 4, 9, 6, 2, 8} <- index 4,5 are out of order, so swap
{1, 3, 5, 7, 4, 6, 9, 2, 8} <- index 5,6 are out of order, so swap,
{1, 3, 5, 7, 4, 6, 2, 9, 8} <- index 6,7 are out of order, so swap
{1, 3, 5, 7, 4, 6, 2, 8, 9} <- index 7,8 are out of order, so swap
First passthrough is now finished
The YouTube videos we watched (available in the links section of the class webpage) also demonstrate this.
8. Maybe a question or two about curses (straight from the reading or in-class code jul26 jul27 directories)
|