1 / 14

Nov 13, 2013 CSCE 1040: Computer Science II Rodney Nielsen

Stack ADT & List Implementation http://www.cse.unt.edu/~Nielsen/1040/ ../~sweany/CSCE1040F13/Home.html. Nov 13, 2013 CSCE 1040: Computer Science II Rodney Nielsen. Midterm & Withdraw Date. Midterm Redo Done with practice questions. Major 3. Major 3 due before 11:55 pm, Nov 22

cael
Download Presentation

Nov 13, 2013 CSCE 1040: Computer Science II Rodney Nielsen

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stack ADT &List Implementationhttp://www.cse.unt.edu/~Nielsen/1040/../~sweany/CSCE1040F13/Home.html Nov 13, 2013 CSCE 1040: Computer Science II Rodney Nielsen

  2. Midterm & Withdraw Date • Midterm Redo • Done with practice questions

  3. Major 3 • Major 3 due before 11:55 pm, Nov 22 • Requires a completed and working Major 2 • Your choice • Get the solution to Major 2, or • Get extra credit toward Major 2 by completing Major 3 without the solution to Major 2 • Contact grader: SiamakJanmohammadi@my.unt.edu • Link to youtube video on the syllabus discussing how to convert an NFA to a DFA, removing epsilon transitions • http://www.youtube.com/watch?v=taClnxU-nao

  4. Extra Credit 1 • Submit reports on bug resolution • What was the error message • Where did you try to find the solution • Were you successful • What was the bug • What was the solution

  5. Extra Credit 2 • NAO robot programs • Get it to do anything interesting • Walk through a maze • Find a person • Move a game piece from one location to another • Recognize a long list of spoken names and say “Hello name!” • Recognize a person from a set of several people and recognize that a person is not in that group • Etc., etc. • nao.cse.unt.edu • Contact jimbglenn@gmail.com

  6. Extra Credit 3 • Testing-related research • This will completely replace your lowest lab grade

  7. Homework by 10:30a M 11/18 • list.c • Due Monday by class time • Implement a select the function prototypes in list.h • Base data type is a room visited in search and rescue • I will provide list.h, but you can add anything you like

  8. Reading • Chapter 10 through 10.9 by Monday

  9. Stack ADT – stack.h Data Type Defns #include <stdio.h> #include <stdlib.h> #define EMPTY 0 #define FULL 10000 typedef char Data; typedef enum {false, true} boolean; struct Elem { Data d; struct Elem* next; } typedef struct Elem Elem; struct Stack { int cnt; Elem* top; } typedef struct Stack Stack;

  10. Stack ADT – stack.h Operations ... struct Stack { intcnt; Elem* top; } typedefstruct Stack Stack; void initialize(Stack* stk); void push(Datad, Stack* stk); Data pop(Stack* stk); Data top(Stack* stk); booleanempty(const Stack* stk); booleanfull(const Stack* stk);

  11. Stack Impl – stack.cinitialize #include "stack.h” /* prototype: voidinitialize(Stack*stk); * struct Stack { * int cnt; * Elem* top; * } * / void initialize(Stack* stk) { stk -> cnt = 0; stk -> top = NULL; }

  12. Stack Impl – stack.cpush #include "stack.h” ... void push(Data d, Stack* stk) { Elem* p; p = malloc(sizeof(Elem)); p -> d = d; p -> next = stk -> top; stk -> top = p; stk -> cnt++; }

  13. Stack Impl – stack.cpop #include "stack.h” … Data pop(Stack* stk) { Data d; Elem* p; d = stk -> top -> d; p = stk -> top; stk -> top = stk -> top -> next; stk -> cnt--; free(p); return d; }

  14. Stack Impl – stack.c #include "stack.h” … Data top(Stack* stk) { return (stk -> top -> d); } boolean empty(const Stack* stk) { return ((boolean) (stk -> cnt == EMPTY)); } boolean full(const Stack* stk) { return ((boolean) (stk -> cnt == FULL)); }

More Related