WGU C173 Scripting and Programming – Foundations Final Objective Assessment What is instantiation? Creating instances of a class What is abstraction?
... [Show More] Focus on the essential qualities of something rather than one specific example. For example, if I say a table you have an idea of what I mean even though I didn't say if it was wood/glass or big/small. This is the essential idea behind creating classes. What is encapsulation? Surrounding something, not just to keep the contents together, but also to protect those contents. Restricts access to the inner workings of a class or any objects based on that class; this is referred to as information hiding or data hiding. What is inheritance? How does inheritance apply to working with classes? A form of code reuse. We can create a new class, but instead of writing it from scratch, we can base it on an existing class. It would inherit some of the characteristics of the base class but could also have its own unique properties and methods that are not shared with the base class. What is polymorphism? How does polymorphism apply to working with classes? Means many forms. It lets us automatically do the correct behavior even if what we're working with could take one of many different forms. The + is a great example. If we're adding two variables together with the plus sign, and these variables are integers, it will numerically add them. But if they are two strings it will concatenate them. With classes this allows us to work with objects created from different classes. What are the differences in a hashed search and a linear search? A linear search goes through each entry one at a time to see if the search word matches the word you are looking for. With a large index and lots of queries this will be a very slow process. A hashed search maps those entries to a number, or keyword, and places those into buckets. This way you know which bucket to start looking at for a particular entry instead of looking through all of the entries. A hashed search is much like looking at the index in the back of a book; if you are looking for "pineapples" you don't have to start at the beginning and read each entry A-P, you can jump to the words that begin with P and start looking there. In this example the letter P would be the bucket that the entry pineapple is placed in. How are buckets used in a hash table? What effect do they have on lookup speed? Entries in a hash table are mapped to a number, which is the position in the index where you should look for the entry. A hash table has numbered bucket slots that hold entries. The entries are organized in the buckets based on their assigned keyword number. When you run a search using a hash table the keyword assigned will be used to determine which bucket the entry should be located in and begin the search there. Because the search knows where to begin looking it is much quicker to look up items. Which storage method covered in this course ensures the fastest access to data? A hash table, or dictionary What is an algorithm? A well-defined sequence of steps (known as a procedure) that will always finish and produce the right results. The algorithm must finish in order for us to analyze efficiency. What is the difference in a procedure and an algorithm? A procedure and algorithm are both a set of instructions that will be executed in order. The difference is that an algorithm must return a value. A procedure, or function, that does not return a value may not be considered an algorithm. What are circular definitions? A definition that constantly calls itself. Because it lacks a base case it has no way to stop. It is stuck in a loop with a reference pointing to another reference that never resolves. These types of definitions are largely helpful in mathematical application. What is a recursive definition? When a function calls itself, it is recursion. If a function is calling itself, it would be stuck in a loop forever unless we have a condition that would allow the recursion to stop. A recursive definition needs to have two parts: the recursive case and the base case. The base case must be something that you already know the answer for and not need to do anything to work it out. This is what allows us to eventually stop running the definition. The recursive case is when the function is calling itself to run again. The recursive case is defined in terms of itself, but in terms of a smaller version of itself, as progress must be made towards the base case. When would you use recursion? To allow us to define infinitely many things using a few simple rules. A simple definition can be used to expand on something much more complex. This involves breaking a problem down into smaller and smaller subproblems until you get to a small enough problem that it can be solved trivially. For example, you could define ancestory = person 1 + ancestors. If you are person 1, your ancestors would be your parents, but they are not your only ancestors. Your parents have parents, but those are still your ancestors. Your grandparents had parents, and so on. A very simple definition can execute with multiple layers and a much more complex value. What three rules must a recursive algorithm obey? It must have a base case which allows it to eventually end. It must change its state and move towards the base case. It must call itself recursively. What do we mean when we talk about the cost of an algorithm? An algorithm's cost is related to the resources that it requires to execute. The primary way cost is discussed is related to the size of the input. Larger inputs usually mean more resources, so this is the main factor that determines the speed. Ultimately this determines the amount of time it takes the algorithm to execute and the amount of memory required to run it. The process of calculating this is called algorithm analysis. What are the two most important factors that affect the cost of an algorithm? Time and memory. Time is the more important factor. How do you prioritize case (best case, worst case, average case) when analyzing algorithms? You would look at them in this order: Worst case, average case, best case. The worst case is the most important because this will give you a better understanding of why the time scales as it does. What is time.clock used for? To check when an algorithm begins and when it ends so that we can determine the run time. This performs benchmarking, which is simply assessing the relative performance of an object. What is UML? Unified Modeling Language. This is a graphical notation specifically for drawing diagrams of an object-oriented system. What are the 5 steps in the UML design process? In which steps do use case, use case diagrams, and class diagrams take place? 1.Gather Requirements 2. Describe the Application (use case and use case diagram) 3. Identify the main objects 4. Describe the interactions between objects 5. Create a class diagram (class diagram) What does a use case provide? A simple narrative for how people use the application. It is written text and there is no coding at this point. This is created after gathering the requirements. What is a title in a use case? This is a short phrase with an active verb that describes the goal. For example, "register new members". What is [Show Less]