CS 223 - Spring 2017. 3/1

Welcome to CS 223!

Logical problem of the day

int main(int argc, char **argv){ 
  char * x = "010";
  int y = 010;
  printf("x: (%s) %d  y: %d\n", x, atoi(x), y);
What happens here?

Lecture 13: HW4 + Data Structures: stacks


  • Office hours:
    The office hours are Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111.
  • My office hours this week are Wednesday 4-5pm.

  • Mid term exam

  • Mid term questionnaire (anonymous). Please fill this out at your earliest convenience. Your comments will be helpful to the instructor and TA's.

  • I spoke with some of you about research positions at SOM. Let me know if you are interested.

  • Piazza outage:
    Dear Piazza User,

    My name is Prithvi and I’m an engineer at Piazza. I wanted to share an update regarding some of the site outages and slowness you may have experienced yesterday. We know that Piazza is essential for your classes and we very much apologize for the inconvenience this must have caused.

    The issues were caused by a widespread issue with Amazon’s AWS S3 service for approximately three hours yesterday, which affected how we serve and upload files. Because of that platform outage, numerous websites across the internet were affected by this issue, and it was unprecedented given AWS’s ubiquitous use across the web.

    The problem has been rectified on Amazon’s side and we’ve confirmed that all is well on our side. We continue to do everything in our power to ensure you have a reliable experience with Piazza.

    Should you have need further assistance or ever have questions, please don't hesitate to reach our support team at team@piazza.com.

    Warm regards,

    Prithvi and the rest of the Piazza Team

    Assignment 4 Problem set 4 Extension until after break.

    Lecture Starts Here


  • For hw4, we do not ask you to expand the stack. If you try to push onto a full stack, the program halts with an error (exit(1)). It is actually easier to make expandable stacks than hash tables. You can implement stacks using linked array structures.
    struct stack {
      struct stack * next;
      int size;
      int top;
      int *elements;
    Imagine an instance where size = 4, and you have pushed the first 9 positive integers. When a stack is full, allocate a new one and have its next point to the old one.
  • Implement a stack using object oriented programming (python): stack.py Note the use of a stack to reverse a string. Also, in python we do not worry about memory allocation or the stack being full.

  • Implement a stack using linked lists: stacklist.c

  • Implement a queue using two stacks: (from last term's final exam): Implement a queue using two stacks. Code: queuetest.c

  • Next topic: trees!