Code Monkey home page Code Monkey logo

cs's Introduction

General Assembly Logo

Computer Science: An introduction

Computer science as an area of study comprises everything necessary for the design, construction, and use of computers.

We'll focus on one area of theoretical computer science, algorithms and data structures, and begin with abstract data types.

Prerequisites

  • Familiarity with a high-level programming language implementing dynamic arrays.

Objectives

By the end of this, developers should be able to:

  • Define abstract data type (ADT).
  • Create stacks and queues from dynamic arrays.

Preparation

  1. Fork and clone this repository.

Abstract data type (ADT)

An ADT is a type defined by what it does, rather than how it is implemented. Specific implementations have limitations not found in the ADT and must be able to create instances of the type.

Stack

A stack implements a last in, first out data store (LIFO).

Discussion: Stack

Stack operations:

  • empty? - check to see if there are any items on a stack.
  • push - add an item onto the top of a stack.
  • pop - remove and return an item from the top of a stack.

Visualizing stack implementations:

Code along: Implementing a stack in JavaScript

Lab: Implementing a stack in Ruby

Queue

A queue implements a first in, first out data store (FIFO).

Discussion: Queue

Queue operations:

  • empty? - check to see if there are any items in a queue.
  • enqueue - add an item to the tail of a queue.
  • dequeue - remove an item from the head of a queue.

Visualizing queue implementations:

Code along: Implementing a queue in JavaScript

Lab: Implementing a queue in Ruby

Language details

In languages that have a "nothing" type, nil in Ruby, undefined in JavaScript, or None in Python, empty? need not be implemented. Instead, check for that type when calling pop or dequeue.

List

Discussion: List

List operations:

  • empty? - check to see if there are any items in a list.
  • first - return the item at the head of a list.
  • rest - return the tail of a list - the list comprised of all elements except the head (the element containing the item returned by first).
  • prepend - create a one element list and add the existing head as its tail.
  • delete - replace a list with rest, removing the head.

Lab: List

In your squads, discuss implementing these operations using an array.

What if this theoretical array type only provided index based access to elements (i.e. the [] operator) and required explicit allocation of space for elements? Would this change your implementation significantly? How would you handle adding an item to a "full" array?

Additional Resources

  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

cs's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.