7 Million Study Materials
From students who've taken these classes before
24/7 Access to Tutors
Personal attention for all your questions
Learn
93% of our members earn better grades
Penn State | CSE 122
Intermed Progrmg
Professors
  • Yoxheimer, Eric Ch,
  • Shaffer, S
 
 
 

37 sample documents related to CSE 122

  • Penn State CSE 122
    C+ History C+ CPL Combined Programming Language (1960s, University of Cambridge, University of London) BCPL Basic Combined Programming Language (1966, Martin Richards, language for writing compilers) GET \"libhdr\" LET start() = VALOF cfw_ FOR i = 1 TO 5 DO
     
  • Penn State CSE 122
    C+ Templates Template is a declaration (similar to class declaration), which deals with generic types. Templates are evaluated to produce concrete classes when a template-base class is instantiated using a concrete type. Templates are powerful because the
     
  • Penn State CSE 122
    C Arrays C arrays are limited: - they are represented by pointers (which may or may not be valid); - Indexes not checked (which means you can overrun your array); - Arrays cannot grow or shrink to accommodate more or less data. C+ Vector = Array with Bene
     
  • Penn State CSE 122
    Containers Hold data and provide access to it. Random-access containers: - Allow accessing any element by index - arrays, vectors Sequential containers: - Allow accessing elements sequentially (i.e. not by index) - queues, stacks, linked lists - Require i
     
  • Penn State CSE 122
    Stack Last In First Out (LIFO) data structure that supports two operations: - push for adding new element at the top of stack - pop for removing new element at the top of stack Stack: Push Stack: Push Joe Max Lex Nika Vlad top Joe Max Lex Nika Vlad top St
     
  • Penn State CSE 122
    Queue Queue First In / First Out (FIFO) data structure that supports two operations: - push for adding new element at the end of the queue - pop for removing new element at the front of the queue Queue: Push Queue: Max Lex Joe Push top Max Lex Nika Vlad J
     
  • Penn State CSE 122
    Recursion Suppose you have a problem involving N data points. Recursive solution of such problem is a follows: If the problem can be solved directly for N points then solve it Else Solve the problem for N-1 and combine this smaller solution with the case
     
  • Penn State CSE 122
    Trees Trees Nonlinear Containers Containers we have studied so far are linear. To represent nonlinear, i.e. hierarchal data we use trees. edge edge edge root node node leaf Tree Terminology Tree root parent node child node leaf (no children) sub-tree Bina
     
  • Penn State CSE 122
    Binary Search Tree (BST) Properties: - Each node has a value - The left subtree contains only values less than the parent nodes value - The right subtree contains only values greater than or equal to the parent nodes value BST Example BST BST Search Algor
     
  • Penn State CSE 122
    Max Heap Properties: - The value in each node is greater than all values in the nodes subtrees - Complete tree! (fills up from left to right) Min Heap Properties: - The value in each node is less than all values in the nodes subtrees Inserting into Max He
     
  • Penn State CSE 122
    Huffman Code Huffman code uses different number of bits to represent characters: - fewer for frequent characters - more for rare characters. Example: e = 10, z = 1001101 Huffman codes are used for data compression. Huffman Tree Huffman Tree is a binary tr
     
  • Penn State CSE 122
    Associative Containers Data Retrieval Sequential Container O(N) Binary Search Tree O(logN) SLOW! How about constant time, O(1)? HOW? Use associative containers (e.g. sets and maps that allow retrieving elements by key)! Sets Definition: Set is an associat
     
  • Penn State CSE 122
    Character to Code Mapping Recall Huffman Codec To find Huffman code for a character one had to search the Huffman tree O(N) Alternatively, one could store Huffman character codes in array, but the linear search is still O(N) SLOW! Some of you stored Huffm
     
  • Penn State CSE 122
    Hash Table How can we retrieve a value (by key) from an associative container in O(1) time? Yes we can, with the help of a Hash Table! Hash table typically implements an internal array for storing data and provides a function for index (i.e. hash code) ca
     
  • Penn State CSE 122
    Selection Sort We are sorting an array of N elements. Algorithm 1) Set currentIndex = 0 2) For each sub-array that starts from currentIndex and goes until the end of the array (N-1): Find the smallest element Swap the smallest element with the one at curr
     
  • Penn State CSE 122
    ExceptionsinC+ Exceptions Exceptionsprovideawaytohandletheerrorsgeneratedbyour programsbytransferringcontroltofunctionscalledhandlers. Tocatchexceptionswehavetoplaceourcodeonwhichwewant exceptionhandlinginthetryblock.Ifanexceptionoccursthecontrolis pass
     
  • Penn State CSE 122
    PointersinC+ TopicsCovered IntroductiontoPointers Pointersandarrays CharacterPointers,ArraysandStrings Examples IntroductiontoPointers Whenwedeclareavariablesomememoryisallocatedforit.The memorylocationcanbereferencedthroughtheidentifieri.Thus,we havetw
     
  • Penn State CSE 122
    Problem Solving 1) 1) 2) 3) 4) Never start coding unless you understand the task! Gather requirements first. This means identify the problem and ask questions about it. Now you kind of know what to do. Analyze requirements to make sure that they are consi
     
  • Penn State CSE 122
    / Inherit1.cpp : Defines the entry point for the console application. / #include \"stdafx.h\" #include <iostream> using namespace std; #define BEGIN { #define END } class Mammal BEGIN public: Mammal():itsAge(1) BEGIN cout < \"Mammal constructor.\ \"; END
     
  • Penn State CSE 122
    / IOtest.cpp : Defines the entry point for the console application. / #include \"stdafx.h\" #include <fstream> #include <iostream> using namespace std; #define BEGIN { #define END } int _tmain(int argc, _TCHAR* argv[]) BEGIN ofstream testout; char infi
     
  • Penn State CSE 122
    #include <iostream> #include <string.h> using namespace std; class String { public: / constructors String(); String(const char *const); String(const String ~String(); / overloaded operators char char operator[](int offse
     
  • peg
    Penn State CSE 122
    #include <iostream> using namespace std; typedef int HANDS; enum COLOR { Red, Green, Blue, Yellow, White, Black, Brown } ; class Animal / common base to both horse and bird { public: Animal(int); virtual ~Animal() { cout < \"Animal destructor.\ \"; } v
     
  • Penn State CSE 122
    /examples of Pure virtual functions /Note syntax #include <iostream> using namespace std; enum COLOR { Red, Green, Blue, Yellow, White, Black, Brown } ; class Animal / common base to both Mammal and Fish { public: Animal(int); virtual ~Animal() { cou
     
  • Penn State CSE 122
    / Win23ConsApp.cpp : Defines the entry point for the console application. / #include \"stdafx.h\" #include \"Win23ConsApp.h\" #ifdef _DEBUG #define new DEBUG_NEW #endif / The one and only application object CWinApp theApp; using namespace std; int _tmain
     
  • Penn State CSE 122
    Recursion Suppose you have a problem involving N data points. Recursive solution of such problem is a follows: If the problem can be solved directly for N points then solve it Else Solve the problem for N-1 and combine this smaller solution with the
    http://www.cse.psu.edu/~mif10/cse122/12-Recursion.ppt
     
  • Penn State CSE 122
    C Arrays C arrays are limited: - they are represented by pointers (which may or may not be valid); - Indexes not checked (which means you can overrun your array); - Arrays cannot grow or shrink to accommodate more or less data. C+ Vector = Array wit
    http://www.cse.psu.edu/~mif10/cse122/8-Vector.ppt
     
  • Penn State CSE 122
    Stack Last In / First Out (LIFO) data structure that supports two operations: - push for adding new element at the top of stack - pop for removing new element at the top of stack Stack: Push Push Joe Max Lex Nika Vlad top Joe Max Lex Nika Vlad
    http://www.cse.psu.edu/~mif10/cse122/10-Stack.ppt
     
  • Penn State CSE 122
    Huffman Code Huffman code uses a different number of bits used to encode characters: it uses fewer bits to represent common characters and more bits to represent rare characters. Huffman codes are used for compressing data files. Huffman Tree Binary
    http://www.cse.psu.edu/~mif10/cse122/16-Huffman%20Code.ppt
     
  • Penn State CSE 122
    Binary Search Tree (BST) Properties: - Each node has a value - The left subtree contains only values less than the parent node\'s value - The right subtree contains only values greater than or equal to the parent node\'s value BST Example BST Search
    http://www.cse.psu.edu/~mif10/cse122/14-BST.ppt
     
  • Penn State CSE 122
    StackandHeapAllocation ProgramAddressSpace Anyprogramyourunhas,associatedwithit,somememorywhichis dividedinto: CodeSegment DataSegment(HoldsGlobalData) Stack(wherethelocalvariablesandothertemporaryinformationisstored) Heap TheHeapgrows do
    http://www.cse.psu.edu/~mif10/cse122/Stack%20and%20Heap%20Allocation.ppt
     
  • Penn State CSE 122
    C+ Classes C+ is about classes A class is a building block, a selfcontained entity providing public data fields (properties) and public operations (methods) for manipulating the class. From the developers stand-point a class may contain private data
    http://www.cse.psu.edu/~mif10/cse122/2-Classes%20&%20Operators.ppt
     
  • Penn State CSE 122
    Sample Program / FileName.cpp / Written by Max Fomitchev (mif10) / This is a sample program / #include <iostream> using namespace std; void main() { } Character Strings / Never hard code constants / Use macro declarations instead #define MAX_LENGTH
    http://www.cse.psu.edu/~mif10/cse122/4-Coding%20Standard%20and%20Best%20Practices.ppt
     
  • Penn State CSE 122
    const Value const declares immutable value void Test(char* t) { t+; t[0] = \'a\'; } / OK, address is not const / OK, char is not const void Test2(const char* t) { t+; / OK, address is not const t[0] = \'a\'; / NO, char is const } const Address typedef
    http://www.cse.psu.edu/~mif10/cse122/6-Const%20%20References%20&%20Pointers.ppt
     
  • Penn State CSE 122
    Containers Hold data and provide access to it. Random-access containers: - Allow accessing any element by index - arrays, vectors Sequential containers: - Allow accessing elements by sequence (not by index) - queues, stacks, linked lists - Require it
    http://www.cse.psu.edu/~mif10/cse122/9-Containers.ppt
     
  • Penn State CSE 122
    Queue Queue First In / First Out (FIFO) data structure that supports two operations: - push for adding new element at the end of the queue - pop for removing new element at the front of the queue Queue: Push Max Lex Joe Push top Max Lex Nika Vla
    http://www.cse.psu.edu/~mif10/cse122/11-Queues%20&%20Deques.ppt
     
  • Penn State CSE 122
    Max Heap Properties: - The value in each node is greater than all values in the nodes subtrees - Complete tree! (fills up from left to right) Min Heap Properties: - The value in each node is less than all values in the nodes subtrees Inserting into
    http://www.cse.psu.edu/~mif10/cse122/15-Heap%20&%20Priority%20Queue.ppt
     
  • Penn State CSE 122
    Get Ready For the Exam: Stacks Etype> Array; a. The default destructor
    http://www.engr.de.psu.edu/cse122/Units/Review1.doc
     
 
 
 
 
7,000,000 study materials • 24/7 tutors • earn better grades
Ask a tutor a question for CSE 122
 
* 
Browse...