Sorting Algorithms and Data Structures for JavaScript

1. Sorting Algorithms 1.1 Bubble Sort Array function sort(arr) { const len = array_length(arr); for (let i = len-1 ; i > 0 ; i = i – 1) { for (let j = 0 ; j < i ; j = j + 1 ) { if (arr[j] > arr[j+1]) { let temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } else { } } } return arr; }

1.2 Selection Sort Array function selection_sort(A) { const len = array_length(A);

for (let i = 0; i < len – 1; i = i + 1) {

let j_min = i; for (let j = i + 1; j < len; j = j + 1) { if (A[

Read More

CIS-265 Test 1 Cheat Sheet

CIS-265 Test 1 Cheat Sheet


Chapter 6

1. Why do local variables lose their values between calls to the function in which they are defined?
They are created in memory when the function begins execution and are destroyed when the function ends.

2. What is the difference between an argument and a parameter variable?
An argument is a value passed to a function and a parameter variable is a variable local to the function which receives the argument. The argument’s value is copied into the parameter variable.

Read More

GRASP Patterns: Assigning Responsibilities to Objects

GRASP Patterns

GRASP stands for General Responsibility Assignment Software Patterns. It guides in assigning responsibilities to collaborating objects. The 9 GRASP patterns are:

  • Creator
  • Information Expert
  • Low Coupling
  • Controller
  • High Cohesion
  • Indirection
  • Polymorphism
  • Protected Variations
  • Pure Fabrication

Responsibility

Responsibility is accomplished by a single object or a group of objects collaboratively. GRASP helps in deciding which responsibility should be assigned to which object or class. It involves identifying

Read More

Understanding Preemptive Scheduling and CPU Performance Metrics

Week 3: What is Preemptive Scheduling?

Preemptive scheduling is used when a process switches from running state to ready state or from the waiting state to ready state. The resources (mainly CPU cycles) are allocated to the process for a limited amount of time and then taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining. That process stays in the ready queue till it gets its next chance to execute. Preemptive schedulers are Round

Read More

Understanding Data Rate, MAC Protocols, and Network Technologies

¡Escribe tu texto aData rate =

Shannon: Max bitrate depends on signal/noise ratio   

Nyquist: Max bitrate depends on n. sampling levels

CSMA CD

  • Is a MAC protocol
  • Exponential back-off strategy -> adapts to load on ethernet
  • RTT bounds determines a bound on throughput

IP tunnels

  • Packets traveling in a tunnel carry IP as load
  • Allows for any IP to be sent to any destination (regardless of the IP carried as load)
  • Never carries Ethernet as load
  • Always carry IP packets as load
  • The service offered by the IP protocol
Read More

Programming Basics and Error Handling

Requirements Phase

Help the customer determine what he/she wants!

  • Sometimes have to help the customer!
  • Document it, including
  • – I/O requirements
  • – Hardware requirements
  • – Speed (throughput) requirements
  • – Software requirements
  • – Functionality desired

For our class

  • Are directions understood and followed?
  • -what the program is supposed to do
  • -input/output requirements
  • -formatting required
  • -correct name for program
  • Is it handed in on the due date?

Design Phase

1.High Level Design

  • Based on Req/Spec Document!
  • Design overall
Read More