Exam 3 Study Guide

Exam 3 Study Guide - Exam 3 Study Guide Recursion 1.What is recursion A recursion function is one that calls itself Recursive functions are used to

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Exam 3 Study Guide Recursion: 1.What is recursion? A recursion function is one that calls itself. Recursive functions are used to reduce a complex problem to a simpler-to-solve problem. 2.What are the advantages and disadvantages of recursion? Benefits (+) Models certain algorithms most accurately Results in shorter, simpler functions disadvantages(-) May not execute very efficiently 3.What is a "base case"? The simpler-to-solve problem is known as the base case. Recursive calls stop when the base case is reached. Do recursive functions require a base case? Yes 4.When should you choose a recursive algorithm over an iterative algorithm? If you cannot find any iterative algorithm for the problem, you have to settle for a recursive one. 5.If a recursive function has no way of stopping, what is likely to happen? It likes infinite loops, it doesn’t have way of stopping continues to repeat until the programs interrupted. Arrays:( variable that can store multiple values of the same type) - How do you declare an array? Using [] operator. Eg. int tests[5] (In the definition int tests[5]; int is the data type of the array elements
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
tests is the name of the array 5, in [5], is the size declarator. It shows the number of elements in the array.) - What is a size declarator? The number inside the brackets is the array’s size declarator. -- more specifically: "The number inside the brackets _in the array declaration_ . .." -- should also mention that the size declarator determines the size of the array (the number of elements you can store in the array) - How are arrays stored in memory? Each element in an array is assigned a unique subscript . Subscripts start at 0 The last element’s subscript is n -1 where n is the number of elements in the array. -- Arrays are stored sequentially in memory. The array name variable itself (with no brackets) stores the address of the first element of the array. - What are the advantages of using a constant for the array size?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/12/2011 for the course CS 2124 taught by Professor Causey during the Spring '11 term at ASU.

Page1 / 8

Exam 3 Study Guide - Exam 3 Study Guide Recursion 1.What is recursion A recursion function is one that calls itself Recursive functions are used to

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online