COMPUTER SCIENCE

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

read

#include <unistd.h> attempts to read up to count bytes from file descriptor fd into the buffer starting at buf.

getting address of variable

& symbol is used to get the address of the variable.

To create, initialize array of pointers dynamically:

(1) Create space for the array arr=malloc(elements*sizeof(type *)) (2) Initialize each value in the array for i = 0 to elements-1 arr[i]=((arr)+i)=malloc(sizeof(type)) (3) Set value of individual elements for i = 0 to elements-1 *(arr[i])=*((arr)+i)=value

Queue

(FIFO)linear structure w/ a particular order in which the operations are performed.

JSON-LD

(JavaScript Object Notation for Linked Data) offers a simpler means to create machine-readable data from websites to promote search results. ... As a result, Google and Bing are embracing JSON-LD because structured data allows developers to easily organize and connect data. Google Search works hard to understand the content of a page. You can help us by providing explicit clues about the meaning of a page to Google by including structured data on the page. Structured data is a standardized format for providing information about a page and classifying the page content; for example, on a recipe page, what are the ingredients, the cooking time and temperature, the calories, and so on. Google uses structured data that it finds on the web to understand the content of the page, as well as to gather information about the web and the world in general. For example, here is a JSON-LD structured data snippet that might appear on a recipe page, describing the title of the recipe, the author of the recipe, and other details: https://developers.google.com/search/docs/guides/intro-structured-data#structured-data

Assume for a directed graph with 10 vertices and 45 edges that a vertex index requires 4 bytes, and a pointer requires 5 bytes. The graph is unweighted, so the adjacency list does not store any weight information. Calculate the byte requirements for an adjacency list.

(V * pointer) + (2 * E * (vertex_index + edge_weight + pointer)) bytes

Assume for an undirected graph with 7 vertices and 15 edges that a vertex index requires 4 bytes, a pointer requires 4 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency list.

(V * pointer) + (2 * E * (vertex_index + edge_weight + pointer)) bytes = (7*4)+(2*15*(4+4+4) =28+(30(12)) =388

Assume for an undirected graph with 9 vertices and 24 edges that a vertex index requires 2 bytes, a pointer requires 6 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency list.

(V * pointer) + (2 * E * (vertex_index + edge_weight + pointer)) bytes = 630 (9*6)+(2*24(2+6+4))=630

Assume for an undirected graph with 6 vertices and 8 edges that a vertex index requires 2 bytes, and a pointer requires 6 bytes. The graph is unweighted, so the adjacency list does not store any weight information. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency list.

(V * pointer) + (2 * E * (vertex_index + pointer)) bytes = 164

Assume for an undirected graph with 10 vertices and 33 edges that a vertex index requires 4 bytes, and a pointer requires 6 bytes. The graph is unweighted, so the adjacency list does not store any weight information. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency list.

(V * pointer) + (2 * E * (vertex_index + pointer)) bytes = =(10*6)+(2*33*(4+6)) =720

Assume for a directed graph with 9 vertices and 22 edges that a vertex index requires 2 bytes, a pointer requires 6 bytes, and that edge weights require 4 bytes. Calculate the byte requirements for an adjacency list.

(V * pointer) + (E * (vertex_index + edge_weight + pointer)) bytes =(9*6)+(22(2+6+4) =318

Assume for a directed graph with 10 vertices and 14 edges that a vertex index requires 2 bytes, a pointer requires 6 bytes, and that edge weights require 3 bytes. Calculate the byte requirements for an adjacency list.

(V * pointer) + (E * (vertex_index + edge_weight + pointer)) bytes = 214

Assume for a directed graph with 8 vertices and 20 edges that a vertex index requires 2 bytes, a pointer requires 4 bytes, and that edge weights require 4 bytes. Calculate the byte requirements for an adjacency list.

(V * pointer) + (E * (vertex_index + edge_weight + pointer)) bytes = 232

Assume for a directed graph with 9 vertices and 34 edges that a vertex index requires 4 bytes, and a pointer requires 4 bytes. The graph is unweighted, so the adjacency list does not store any weight information. Calculate the byte requirements for an adjacency list.

(V * pointer) + (E * (vertex_index + pointer)) bytes = 308

how to get the value of a variable that the pointer is pointing to

* symbol #include <stdio.h> int main() { int *ptr, q; q = 50; /* address of q is assigned to ptr */ ptr = &q; /* display q's value using ptr variable */ printf("%d", *ptr); return 0; }

is-a relationship means:

- All subclass inherits all attributes and methods of parent class - Subclass can override method of parent class - Subclass can have additional method that parent class doesn't have

common causes of segmentation fault

- Improper format control string in printf or scanf statements: - Forgetting to use "&" on the arguments to scanf. CORRECT: scanf("%c", &ch); - Accessing beyond the bounds of an array: - Failure to initialize a pointer before accessing it: - Incorrect use of the "&" (address of) and "*" (dereferencing) operators:

What are the two requirements that code in the method that can potentially throw a checked exception must have one of or else the code won't compile?

- It must handle the exception or - It must have a throws clause listed in the method header

Inner Class:

- Nested Inner class - Method Local inner classes - Anonymous inner classes - Static nested classes

Steps of Compilation

- Preprocessing (all statements beginning w/ # in source code) - Compilation (turns c into assembly) -Assembly (turns assembly into machine code) -Linking (produce executable program by rearranging pieces and filling in the missing ones)

system calls vs. library routines

- System calls are entry points into kernel code where their functions are implemented. ((Documented in section 2 of the manual. ($man 2 <name>))) - Library calls are transferred to user code which performs the desired functions. ((Documented in section 3 of the manual. ($man 3 <name>)))

file access permission

- access and faccessat - umask - chmod, fchmod, fchmodat

4 Steps of Machine Cycle

- fetch -decode -execute -store

stdin

- file descriptor is 0 - pointers to FILE structure - file defined by the standard c library

stdout

- file descriptor is 1 - pointers to FILE structure

stderr

- file descriptor is 2 - pointers to FILE structure

.net

- free, open source, cross platform developer environment - common runtime with extensive class libraries - develop in multiple languages - build web apps, mobile apps, desktop, games, loT(internet of things), etc. - BASIC language targeting the .NET Framework - Fully integrated into Visual Studio - Supported and updated by Microsoft as each new version of VB.NET comes out

Why choose VB.NET

- it is object oriented, type-safe, quick and easy to build .NET applications

what are the two key abstractions a process provides for a program?

- logical control flow - private address space

Dynamic type

- once compiler doesn't complain, you can run the program. Dynamic type decides which method is called. (performs checking during run time) - while dynamically-typed languages do not require you to declare the data types of your variables before you use them. -

what methods obtain process IDs?

- pid_t getpid(void) -- returns PID of current process - pid_t getppid(void) -- returns PID of parent process

three reasons a process would be terminated

- receiving a signal whose default action is to terminate - returning from the main routine - calling the exit function

Two types of list data type

- the linked list - the array-based list The list data type therefore can be implemented using a linked list or an array list

Static type

- used by compiler - statically-typed languages require you to declare the data types of your variables before you use them,

VMware

-Makes the most widely implemented virtualization software -Provides several which are designed for managing virtual workstations on a single host

What are the main components of a CPU

-registers -control unit -arithmetic logic unit

value of a null pointer

0 Always C pointer is initialized to null, i.e. int *p = null.

umask value for others-execute

0001

umask value for others-write

0002

umask value for others-read

0004

umask value for group-execute

0010

umask value for group-write

0020

umask value for group-read

0040

umask value for user-execute

0100

umask value for user-write

0200

Beginning address of RAM

0200h

umask value for user-read

0400

End address of RAM

0500h (depends on amnt of RAM present)

End address for flash/ROM

0x0FFFF (for devices w/ <60KB)

When selecting a data structure to solve a problem, you should follow these steps:

1. Analyze your problem to determine the basic operations that must be supported. Examples of basic operations include inserting a data item into the data structure, deleting a data item from the data structure, and finding a specified item. 2. Can data items be deleted? If so, this will probably make the implementation more complicated. 3. Are all data items processed in some well-defined order, or is search for specific data items allowed? "Random access" search generally requires more complex data structures.

file I/O

1. Declare a pointer of type FILE * for each file to be active at the same time. This pointer points to a FILE structure. Then call fopen(), passing it file to be opened and the mode, whether reading, or writing or both to open a stream. fopen() returns a pointer to FILE structure. Every stream has a FILE structure associated with it. This pointer can be used to access its associated stream. fopen() and operating system may verify whether the given file exists, and on some implementations, operating system may check if you have required permissions for accessing the file in the way you have specified and initializes the FILE structure. 2. Next step is to use the FILE structure to perform I/O from and to the files. 3. After you are done with the file I/O, call the fclose() function, passing it FILE structure associated with a given stream to close the stream and releasing the file pointer for use by other stream when needed. Closing the stream prevents you from accessing the associated file again and guarantees that stream buffer is flushed to the file. Let's take a simple C program to see difference. /* * fopen_fclose.c -- program attempts to open, process and * close files one by one */ #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int exit_status = EXIT_SUCCESS; FILE *fp; int ch; printf("**Program reads in file names as command-line arguments,\n" "attempts to open stream associated with each file in read " "mode\nthen reads from each file one-by-one, before closing" " each.**\n"); while (*++argv != NULL) { /* open files */ fp = fopen(*argv, "r"); /* test if fopen succedded */ if (fp == NULL) { /* give user error massage */ printf("No such %s file", *argv); /* not to exit, instead process another */ /*file name if there's any */ exit_status = EXIT_FAILURE; continue; } /* here we process file */ /* read the contents of the file line by line */ while ((ch = fgetc(fp)) != EOF) { putchar(ch); } putchar('\n'); /* Now we close the stream by passing fp to fclose() */ /* also test if fclose did not fail */ if (fclose(fp) != 0) { perror("fclose(): *argv"); exit(EXIT_FAILURE); } } }

Hardware vendor XYZ Corp. claims that their latest computer will run 100 times faster than that of their competitor, Prunes, Inc. If the Prunes, Inc. computer can execute a program on input of size nnn in one hour, what size input can XYZ's computer execute in one hour for an algorithm whose growth rate is n^2? 10 10n10n10n n+100n+100n+100 100100100 n2n^2n​2​​ 10n210n^210n​2​​ 100n100n100n 100n2100n^2100n​2​​ nnn n+10n+10n+10

10n

Hardware vendor XYZ Corp. claims that their latest computer will run 10 times faster than that of their competitor, Prunes, Inc. If the Prunes, Inc. computer can execute a program on input of size n in one minute, what size input can XYZ's computer execute in one minute for an algorithm whose growth rate is 3n-9?

10n-27

How many keys can a btree store

124

Char size for Java

2 bytes

How many bytes is a word

2 bytes

Short size for Java

2 bytes

how many bits are an int?

4

Each hex character has how many bits?

4 binary bits

Float size for Java

4 bytes

Integer size for Java

4 bytes

How many bits are in a byte?

8

Double size for Java

8 bytes

Long size for Java

8 bytes

Harvard Architecture

A computer architecture with physically separate storage and signal pathways for instructions and data. These early machines had data storage entirely contained within the central processing unit, and provided no access to the instruction storage as data.

daemon

A daemon is a type of program on Unix-like operating systems that runs unobtrusively in the background, rather than under the direct control of a user, waiting to be activated by the occurance of a specific event or condition. Unix-like systems typically run numerous daemons, mainly to accommodate requests for services from other computers on a network, but also to respond to other programs and to hardware activity. Examples of actions or conditions that can trigger daemons into activity are a specific time or date, passage of a specified time interval, a file landing in a particular directory, receipt of an e-mail or a Web request made through a particular communication line. It is not necessary that the perpetrator of the action or condition be aware that a daemon is listening, although programs frequently will perform an action only because they are aware that they will implicitly arouse a daemon. Daemons are usually instantiated as processes. A process is an executing (i.e., running) instance of a program. Processes are managed by the kernel (i.e., the core of the operating system), which assigns each a unique process identification number (PID). There are three basic types of processes in Linux: interactive, batch and daemon. Interactive processes are run interactively by a user at the command line (i.e., all-text mode). Batch processes are submitted from a queue of processes and are not associated with the command line; they are well suited for performing recurring tasks when system usage is otherwise low. Daemons are recognized by the system as any processes whose parent process has a PID of one, which always represents the process init. init is always the first process that is started when a Linux computer is booted up (i.e., started), and it remains on the system until the computer is turned off. init adopts any process whose parent process dies (i.e., terminates) without waiting for the child process's status. Thus, the common method for launching a daemon involves forking (i.e., dividing) once or twice, and making the parent (and grandparent) processes die while the child (or grandchild) process begins performing its normal function. Some daemons are launched via System V init scripts, which are scripts (i.e., short programs) that are run automatically when the system is booting up. They may either survive for the duration of the session or be regenerated at intervals. Many daemons are now started only as required and by a single daemon, xinetd (which has replaced inetd in newer systems), rather than running continuously. xinetd, which is referred to as a TCP/IP super server, itself is started at boot time, and it listens to the ports assigned to the processes listed in the /etc/inetd.conf or in /etc/xinetd.conf configuration file. Examples of daemons that it starts include crond (which runs scheduled tasks), ftpd (file transfer), lpd (laser printing), rlogind (remote login), rshd (remote command execution) and telnetd (telnet).

Composite data type

A data type that allows a collection of values to be associated with an object of that type

In computer science a metaphor is: - A label applied to a group of concepts - A comparison that does not use the word 'like' - A figure of speech in which a phrase is applied to an object to which it is not literally applicable - The model of a type

A label applied to a group of concepts

framework

A language is just a minimal set of rules for doing things. As an example, let's say I'm a scientist, and I want to calculate the derivative of a function at some point. I could either do this from scratch myself, figuring out the algorithm and writing all the necessary bits of code. Or I could simply utilize a framework or library, in which someone else has solved all of these problems and done the leg work for me, and I just use a simple interface to do what I want e.g. result = Framework.differentiate(function) et voila.

disadvantages of a queue

A major disadvantage of a classical queue is that a new element can only be inserted when all of the elements are deleted from the queue.

Which is true about the relationship between algorithms and problems? A problem is a mapping from inputs to outputs. Since this mapping is fixed, there is only one right way to compute the mapping. A problem is a mapping from inputs to outputs, and there might be many algorithms that can accomplish this mapping. An algorithm is another term for a problem. A problem is a recipe, and an algorithm is a solution to a problem.

A problem is a mapping from inputs to outputs, and there might be many algorithms that can accomplish this mapping.

Von Neumann Architecture

A processor where data and instructions are stored in the same memory and accessed via buses.

Which is the best definition for algorithm? A program A recipe A mapping from input to output

A recipe

Microsoft SQL Server

A server application that hosts databases accessible from web servers and a wide array of applications

struct

A structure is a user defined data type in C. A structure creates a data type that can be used to group items of possibly different types into a single type. struct address { // cannot initialize // variables here char name[50]; char street[100]; char city[50]; char state[20]; int pin; };

hierarchical file system

A structured file organization system in which the root directory (also called a folder) may contain other directories, which in turn contain files.

What is the difference between a try block and a catch block?

A try block is one or more statements executed that can potentially throw an exception and a catch block or "catch clause" is the portion of code that executes and handles the exception if an exception is thrown (has to match the ExceptionType for that catch block)

A composite type is: - A type composed from at least one simple type - A type comprised of other types - An instance of a class - Another term for an Abstract Data Type

A type comprised of other types

Difference between an abstract class and an interface

Abstract class cannot be instantiated, but is intended to serve as a super class. and the abstract method has no body and must be overridden in superclass. Interface cannot be instantiated, and this specifies the behavior for a class

An ADT is a form of: - Abstraction - Design - Metaphor - Simile - Programming

Abstraction

What does abstraction and encapsulation do?

Abstraction allows for specialization and encapsulation hides attributes(including data) in objects. Objects are designed to only reveal the necessary data, allowing software to interact with the object on a higher level.

Assume for an undirected graph with 6 vertices and 13 edges that a vertex index requires 4 bytes, and a pointer requires 6 bytes. The graph is unweighted, so the adjacency list does not store any weight information. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency list.

Adjacency list has an array (of size |V|) which points to a list of edges. Every edge appears twice on the list (the graph is undirected, so we need the directed edge in each direction). And for each edge there has to be a vertex ID and a pointer to the next edge. (V * pointer) + (2 * E * (vertex_index + pointer)) bytes = 296

A tool for measuring the efficiency of an algorithm or problem is:

Algorithm analysis

A tool for measuring the efficiency of an algorithm or problem is: Algorithm analysis Empirical analysis A profiler The system clock

Algorithm analysis

The mid-squares method hash function makes use of:

All of the digits or bits of the key

Which of these is the best definition for a stable sorting algorithm? An algorithm that does not change the relative ordering of records with identical keys An algorithm that always gives the same order for duplicate keys from run to run An algorithm that is as fast as the best one known An algorithm that always gives the right answer

An algorithm that does not change the relative ordering of records with identical keys

Which of these is the best definition for a stable sorting algorithm? An algorithm that always gives the same order for duplicate keys from run to run An algorithm that is as fast as the best one known An algorithm that always gives the right answer An algorithm that does not change the relative ordering of records with identical keys

An algorithm that does not change the relative ordering of records with identical keys

Briefly describe what an exception is.

An exception is an object formed in memory When an error occurs within a method or class. the method hands the exception off to the runtime system

dereferencing invalid pointers (seg fault)

An invalid pointer reference occurs when a pointer's value is referenced even though the pointer doesn't point to a valid block. One way to create this error is to say p=q;, when q is uninitialized. The pointer p will then become uninitialized as well, and any reference to *p is an invalid pointer reference.

Exception?

An object generated from the Java API as a result of an error or an unexpected event

Linux

An open source software operating system.

computer system

An organization of hardware and software designed to accomplish a data processing function.

Angular

Angular is a platform and framework for building single-page client applications using HTML and TypeScript. Angular is written in TypeScript. It implements core and optional functionality as a set of TypeScript libraries that you import into your apps.

What is Java API

Application Programmer Interface - collection of pre-written classes and methods for performing specific operations

How is a linked list implemented?

As a sequence of nodes, where each node stores a list element and a reference to the next node in the list

BTree

B-tree is a self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. The B-tree is a generalization of a binary search tree in that a node can have more than two children.

Write an MSP430 assembly instruction to configure pins p1.1, p1.3, and p1.4 as outputs.

BIS.B #BIT1,&P1DIR BIS.B #BIT3,&P1DIR BIS.B #BIT4,&P1DIR

How does OOP reduce data corruption?

Because you can make an objects fields private so that you can control the way a user inputs or changes the data

Node colorList = new Node("Yellow", new Node("Purple")); colorList=newNode("Brown", colorList); System.out.print(colorList.value); System.out.print(colorList.next.value) System.out.print(colorList.next.next.value)

BrownYellowPurple

What does a file with the extension .class contain?

Byte code (this file is made after there are no errors/it runs correctly AND this file has same name as java file

R3

CG2(Constant Generator 2)

What does a throws statement do?

Causes an exception to be thrown

all of the exceptions that DO NOT inherit from the Error class or the RunTimeException class are what kind of exceptions?

Checked, you should handle these in your program

What are the benefits of OOP

Code reuse, reduce data corruption, abstraction and encapsulation, reduce complexity

TCP/IP PROTOCOL SUITE

Communications between computers on a network is done through protocol suits. The most widely used and most widely available protocol suite is TCP/IP protocol suite. A protocol suit consists of a layered architecture where each layer depicts some functionality which can be carried out by a protocol. Each layer usually has more than one protocol options to carry out the responsibility that the layer adheres to. TCP/IP is normally considered to be a 4 layer system. The 4 layers are as follows : 1. Application layer 2. Transport layer 3. Network layer 4. Data link layer

FileOutputStream

Connects PrintWriter to a text file; - is used to create a file and write data into it. - The stream would create a file, if it doesn't already exist, before opening it for output. ex1: OutputStream f = new FileOutputStream("C:/java/hello") ex2: File f = new File("C:/java/hello"); OutputStream f = new FileOutputStream(f);

continue or c

Continue program

symbolic links

Create a symbolic link to an individual file or folder, and that link will appear to be the same as the file or folder, even though it's just a link pointing at the file or folder.

What actually writes to file once you connect to file?

DataOutputStream

Thread

Each process (application) in OS X or iOS is made up of one or more threads, each of which represents a single path of execution through the application's code. Every application starts with a single thread, which runs the application's main function. Applications can spawn additional threads, each of which executes the code of a specific function. When an application spawns a new thread, that thread becomes an independent entity inside of the application's process space. Each thread has its own execution stack and is scheduled for runtime separately by the kernel. A thread can communicate with other threads and other processes, perform I/O operations, and do anything else you might need it to do. Because they are inside the same process space, however, all threads in a single application share the same virtual memory space and have the same access rights as the process itself.

Unchecked exceptions inherit from what class?

Error class or the RunTimeException class. we should not handle these exceptions because the conditions that cause them can rarely be dealt with in the program

What are the two direct subclasses of the Throwable class?

Error class, Exception class

standard I/O

Every runtime environment must provide three streams viz. standard input, standard output and standard error to every C program. These streams are stdin, stdout and stderr and these are pointers to FILE structure. stdin is default to read from a device which is mostly a keyboard, stdout writes default to a output device which is mostly a terminal or user screen. stderr writes error messages default to terminal or user screen. perror() function writes its error messages to a place where stderr writes its own. A C program which communicates interactively uses these default streams to perform input and/or output to default devices. For ex. #include <stdio.h> int main(void) { char *str; printf("how are you, dear xyz?\n"); gets(str); return 0; }

buffer overflows (seg fault)

Example: char buff[10]; buff[10] = 'a'; char *ptr = (char*) malloc(10); ptr[10] = 'c'; char buff[10] = {0}; strcpy(buff, "This String Will Overflow the Buffer");

What are the two file names used?

Example: outputStream and out.txt

If a subclass constructor does not implicitly call the parent classes constructor, it will not call the parents constructor. T or F

F, it automatically calls the parents no arg constructor

A company wants to use a system where they randomly assign each customer a 9-digit ID (so there are 1 billion possible ID numbers). Of course, there is a chance that two customers will be assigned the same ID. But the company figures that risk is OK if the odds are small enough. They expect to assign IDs to 1000 customers. The chance of a collision is therefore one in a million. True False

False

A problem is an instantiation of an algorithm implemented in a specific programming language. True False

False

A program maps inputs to outputs. True False

False

For the string hash functions, the size of the hash table limits the length of the string that can be hashed. True False

False

In an array-based list implementation, to access the predecessor of the current node we must start at the first node in the list. True False

False

The lower bound for the cost of sequential search is Ω(1) since this is the running time of the algorithm in the best case. T or F

False

There is only one way that a given problem can be solved. True False

False

When solving a computational problem or designing a software applications, a problem instance deals with the range of values the problem input can take. T or F

False

T or F, you cannot have more than one catch clause per try statement

False,

file descriptor vs file pointer

File descriptor is an integer which is an index in the kernel on the opened files It is used to deal with the files . most of the functions like open,close,read using the file descriptors to deal with the files. File pointer is a location within the file which points the next character which going to read.

What connects to file when you want to write to it?

FileOutputStream ex.) FileOutputStream fstream = new FileOutputStream("MyInfo.dat");

How to write to a file?

FileOutputStream and DataOutputStream

reference variable r refers to a serializable object. write code that serializes the object to the file ObjectData.dat

FileOutputStream outStream = new FileOutputStream("Object.dat"); ObjectOutputStream objectOutputFile - new ObjectOutputStream(outStream); objectOutputFile.writeObject(r);

The Queue is best characterized as:

First-In, First-Out

environment variables

HOME, PATH, SHELL, USER, LOGNAME, last is NULL

entity framework

Helps us interact with the database

Line buffered

I/O is performed when a newline character is encountered on input or output; typically used on a stream when it refers to a terminal.

When to use stack vs heap

If you need to allocate a large block of memory (e.g. a large array or a big struct), then allocate it on the heap. Or, if you need to change size dynamically of the variables. If you are dealing with small variables that only need when function is alive, then you should use a stack since it is easier and faster.

hashing

In hashing there is a hash function that maps keys to some values. But these hashing function may lead to collision that is two or more keys are mapped to same value. Chain hashing avoids collision. The idea is to make each cell of hash table point to a linked list of records that have same hash function value.

If multiple exceptions can be thrown by code in a try block, how does the JVM know which catch clause it should pass the control of the program to?

In order for a catch clause to be able to deal with an exception, its parameter must be of type that is compatible with the exception's type.

What kind of situations does the IOException handle?

Input and output operations

ASPX

It is a server-generated webpage that contains scripts, which are processed on the web server and the resulting HTML is sent to the user's web browser. ASPX files are often written with Microsoft Visual Web Developer and designed for the Microsoft ASP.NET framework. ASPX pages are also called ".NET Web forms."

Which of these is NOT a definition for efficiency in a computer program? It solves the problem within the required resource contraints It requires fewer resources than known alternatives It runs in linear time

It runs in linear time

dynamic binding

JVM determines at runtime which method to call. depending on the type of the object that a variable references

Encapsulation

Keeping details (like data and procedures) together in one part of a program so that programmers working on other parts of the program don't need to know about them.

what are the two important divisions in UNIX operating system?

Kernel and shell

LINQ

Language Integrated Query

LINQ

Language Integrated Query, which is a language to help simplify working with collections

benefits of a linked list

Linked List is Dynamic data Structure . Linked List can grow and shrink during run time. Insertion and Deletion Operations are Easier. Efficient Memory Utilization ,i.e no need to pre-allocate memory. Faster Access time,can be expanded in constant time without memory overhead.

memory leaks (seg fault)

Memory leak occurs when programmers create a memory in heap and forget to delete it. /* Function without memory leak */ #include <stdlib.h>; void f() { int *ptr = (int *) malloc(sizeof(int)); /* Do some work */ //if you don't have free, then memory that was //allocated is not deleted, causing a memory-leak free(ptr); return; }

In an array-based list, the successive elements in the list: Need not occupy contiguous space in memory Must not occupy contiguous space in memory None of these Must occupy contiguous space in memory

Must occupy contiguous space in memory

Give a sequence of statements that creates a linked list of strings "red green blue" by creating a node with "green" then a node w/ "blue" then a node with "red" in that order

Node myList = new Node("green") myList.next = new Node("Blue") Node p = new Node("red")

The numeric wrapper classes "parse" methods all throw an exception of this type if the string being converted does not contain a numerical value

NumberFormatException

Consider a singly linked list of n nodes. It has a head pointer and a cur pointer. Cur points to a node that is under consideration. What is the time taken (most efficient) to insert a new node after the node pointed by cur?

O(1)

When implementing Insertion Sort, a binary search could be used to locate the position within the first i-1i−1 records of the array into which record ii should be inserted. In this implementation, the worst case time will be:

O(n^2)

What are the two primary methods of programming?

Object Oriented Programming and Procedural

read(2)

On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may hap‐ pen for example because fewer bytes are actually available right now (maybe because we were close to end-of- file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal. On error, -1 is returned, and errno is set appropriately. In this case it is left unspecified whether the file position (if any) changes.

How many copies of a static variable can you have?

One, one copy is shared with all classes/instances

Types of Java Classes:

POJO Class Static Class Concrete Class Abstract Class Final Class Inner Class: - Nested Inner class - Method Local inner classes - Anonymous inner classes - Static nested classes

POJO class (Java)

POJO stands for Plain Old Java Object. It is an ordinary Java object, not bound by any special restriction other than those forced by the Java Language Specification and not requiring any class path. POJOs are used for increasing the readability and re-usability of a program. As we know that in Java POJO refers to the Plain old Java object. POJO and Bean class in Java shares some common features which are as follows − Both classes must be public i.e accessible to all. Properties or variables defined in both classes must be private i.e. can't be accessed directly. Both classes must have default constructor i.e no argument constructor. Public Getter and Setter must be present in both the classes in order to access the variables/properties. The only difference between both the classes is Java make java beans objects serialized so that the state of a bean class could be preserved in case required.So due to this a Java Bean class must either implements Serializable or Externalizable interface. Due to this it is stated that all JavaBeans are POJOs but not all POJOs are JavaBeans. Example of Java Bean Class. public class Employee implements java.io.Serializable { private int id; private String name; public Employee(){} public void setId(int id){this.id=id;} public int getId(){return id;} public void setName(String name){this.name=name;} public String getName(){return name;} } Example of POJO Class. public class Employee { String name; public String id; private double salary; public Employee(String name, String id,double salary) { this.name = name; this.id = id; this.salary = salary; } public String getName() { return name; } public String getId() { return id; } public Double getSalary() { return salary; } }

c pointers

Pointers in C language is a variable that stores/points the address of another variable. A Pointer in C is used to allocate memory dynamically i.e. at run time. The pointer variable might be belonging to any of the data type such as int, float, char, double, short etc.

what methods are used to open a text file for output?

PrintWriter and FileOutputStream Ex.) FileOutputStream s = new FileOutputStream("out.txt"); PrintWriter outputStream = new PrintWriter(s);

R0

Program Counter: points to next instruction to be executed

PHP (Hypertext Preprocessor)

Programming language used to build websites with interactive capabilities; adapts the HTML page to the user's selections.

BIS.W #0x08, R5

Set bits in destination using OR operation

R1

Stack pointer: stores return address of routines or interrupts on the stack

run

Start program

R2

Status Register/Constant Generator - defined by a set of bits contained in R2

The lower bound for a problem is defined as the least cost that any algorithm could reach. T or F

T

Sorting Problem allows input with two or more records that have the same key value. T or F

TRUE

Which of these will NOT affect the RELATIVE running times for two sorting algorithms? The number of records The CPU speed The allowable range for the record values The amount by which the values are out of order

The CPU speed

HTML DOM

The Document Object Model is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree.

What is the difference between exceptions that inherit from the Error class and exceptions that inherit from the Exception class?

The Error class handles exceptions for when the error is out the programmers control/critical errors and the Exception class are exceptions the programmer will handle

When is Insertion Sort a good choice for sorting an array?

The array contains only a few records

catch block

The catch block will be used whenever an exception (of the type caught) is thrown in the try block

What do instance fields belong to?

The class, not the object

content of a c pointer

The content of the C pointer always be a whole number i.e. address.

What is the primary difference between the von Neumann architecture and the Harvard architecture

The data and instructions in Harvard are separate and they are together in the von Neumann architecture

What happens if your code does not handle an exception when it is thrown?

The default exception handler deals with it, which prints an error message and crashes the program

Working Directory / current directory

The directory in the file system you are currently "in".

A program's main method calls method A, which calls method B. None of these methods performs any exceptions handling. The code in method B throws an exception. Describe what happens.

The exception is dealt with by the default exception handler. The error message printed will show a stack trace listing the methods that were called in order to produce the exception. The first method listed is the method responsible for the exception. The next method is the method that called the method that produced the error, and so on..

finally block

The finally block is called in every case after the try/catch blocks. Even if the exception isn't caught or if your previous blocks break the execution flow.

What is the first element in the linked list called?

The head

The binning hash function makes use of:

The high order digits or bits in the key

The simple mod hash function makes use of:

The low order digits or bits in the key

Assume for a directed graph with 7 vertices and 10 edges that a vertex index requires 2 bytes, and a pointer requires 5 bytes. The graph is unweighted, so assume that each matrix element stores one byte to represent the edge. Calculate the byte requirements for an adjacency matrix.

The matrix is |V| by |V| Each position of the matrix needs 1 byte V^2 * 1 bytes = 49

Assume for an undirected graph with 7 vertices and 14 edges that a vertex index requires 2 bytes, a pointer requires 4 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

The matrix is |V| by |V| The adjacency matrix needs the same amount of space regardless of whether the graph is directed or undirected. Each position of the matix needs 4 bytes V^2 * edge_weight bytes = 1V^2 * edge_weight bytes = 19696

Assume for an undirected graph with 8 vertices and 9 edges that a vertex index requires 2 bytes, a pointer requires 6 bytes, and that edge weights require 3 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

The matrix is |V| by |V| The adjacency matrix needs the same amount of space regardless of whether the graph is directed or undirected. Each position of the matrix needs 3 bytes: V^2 * edge_weight bytes = 192

Assume for an undirected graph with 10 vertices and 24 edges that a vertex index requires 3 bytes, a pointer requires 4 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

The matrix is |V| by |V| The adjacency matrix needs the same amount of space regardless of whether the graph is directed or undirected. Each position of the matrix needs 4 bytes V^2 (100) * edge_weight bytes(4)= 400

Which of these is a traditional measure for the cost of a sorting algorithm? The amount by which the values are out of order The number of records The memory size The number of comparisons

The number of comparisons

Which of these is a traditional measure for the cost of a sorting algorithm? The number of comparisons The amount by which the values are out of order The number of records The memory size

The number of comparisons

Which of these is a traditional measure for the cost of a sorting algorithm? The number of swaps The memory size The amount by which the values are out of order The number of records

The number of swaps

O(f(n))

The set of functions that grows no faster than f(n) ● asymptotic upper-bound on growth rate

Ω( f(n) )

The set of functions that grows no slower than f(n) ● asymptotic lower-bound on growth rate

Apache server software

The software used by a vast majority of web servers

An ADT is:

The specification of a data type within some language, independent of an implementation

After the catch block has handled the exception, where does program execution resume?

The statement directly under the catch block.

What is the last element in the linked list called?

The tail

throw

The throw keyword will allow you to throw an exception (which will break the execution flow and can be caught in a catch block).

throws

The throws keyword in the method prototype is used to specify that your method might throw exceptions of the specified type. It's useful when you have checked exception (exception that you have to handle) that you don't want to catch in your current method.

try block

The try block will execute a sensitive code which can throw exceptions

flclose()

This function causes stream to be closed and the connection to the corresponding file to be broken. Any buffered output is written and any buffered input is discarded. The fclose function returns a value of 0 if the file was closed successfully, and EOF if an error was detected. It is important to check for errors when you call fclose to close an output stream, because real, everyday errors can be detected at this time. For example, when fclose writes the remaining buffered output, it might get an error because the disk is full. Even if you know the buffer is empty, errors can still occur when closing a file if you are using NFS. The function fclose is declared in `stdio.h'.

The HTML <head> Element

This is how every HTML document is started off. The <title> tag might be something new to you. Since it's placed within our <head>, our users are not able to see this <title> on their screen. But their browser does display it on the page tab.

The html <nav> element

This is the HTML element that stores our navigation links. We then create a list within our <nav>using an unordered list aka a <ul>. Using <a href> tags, we place our links within an <li>.

Application layer

This is the top layer of TCP/IP protocol suite. This layer includes applications or processes that use transport layer protocols to deliver the data to destination computers. At each layer there are certain protocol options to carry out the task designated to that particular layer. So, application layer also has various protocols that applications use to communicate with the second layer, the transport layer. Some of the popular application layer protocols are : HTTP (Hypertext transfer protocol) FTP (File transfer protocol) SMTP (Simple mail transfer protocol) SNMP (Simple network management protocol) etc

Network Layer

This layer is also known as Internet layer. The main purpose of this layer is to organize or handle the movement of data on network. By movement of data, we generally mean routing of data over the network. The main protocol used at this layer is IP. While ICMP(used by popular 'ping' command) and IGMP are also used at this layer.

Data Link Layer

This layer is also known as network interface layer. This layer normally consists of device drivers in the OS and the network interface card attached to the system. Both the device drivers and the network interface card take care of the communication details with the media being used to transfer the data over the network. In most of the cases, this media is in the form of cables. Some of the famous protocols that are used at this layer include ARP(Address resolution protocol), PPP(Point to point protocol) etc.

Transport Layer

This layer provides backbone to data flow between two hosts. This layer receives data from the application layer above it. There are many protocols that work at this layer but the two most commonly used protocols at transport layer are TCP and UDP.

Other than the object class, what is the superclass for all exceptions?

Throwable class

Which of these is more a concern for Software Engineering than for a data structures course?

To design an algorithm that is easy to understand, code, and debug

Which of these is more a concern for Software Engineering than for a data structures course? To design an algorithm that makes efficient use of the computer's resources To design an algorithm that is easy to understand, code, and debug

To design an algorithm that is easy to understand, code, and debug

Why should you handle exceptions?

To prevent the exceptions from crashing your program

A linked list is a recursive data structure, T or F

True

A problem instance is a specific selection of values for the problem input. True False

True

A program is an instantiation of an algorithm implemented in a specific programming language. True or False

True

Insertion Sort (as the code is written in this module) is a stable sorting algorithm. Recall that a stable sorting algorithm maintains the relative order of records with equal keys. T or F

True

T or F: the head of a linked list is also a linked list

True

Which is the best definition for collision in a hash table?

Two records with different keys have the same hash value

typescript

TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. TypeScript is designed for development of large applications and transcompiles to JavaScript.

exceptions that inherit from the Error class or the RunTimeException class are what kind of exceptions?

Unchecked

What are the differences between a checked and an unchecked exception?

Unchecked exceptions are caused by critical errors out of the programmers control and should not be handled by the programmer and checked exceptions must be dealt with by programmer or else the JVM will not compile the code

stat() function

Unix system call that returns file attributes about an inode - writes it to the area pointed to by the buf argument. The path argument points to a pathname naming a file. - Read, write, or execute permission of the named file is not required.

For the 'improved' string hash function that sums up 32-bit values each generated by 4 characters at a time, does the output change when the order of the letters changes?

Usually

Assume for an undirected graph with 7 vertices and 9 edges that a vertex index requires 4 bytes, and a pointer requires 5 bytes. The graph is unweighted, so assume that each matrix element stores one byte to represent the edge. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

V2 = 7^2 = 49 Edge weight: 1 V^2*Efgeweight = 49

Assume for a directed graph with 8 vertices and 17 edges that a vertex index requires 2 bytes, and a pointer requires 4 bytes. The graph is unweighted, so assume that each matrix element stores one byte to represent the edge. Calculate the byte requirements for an adjacency matrix.

V^2 * 1 bytes =64

Assume for a directed graph with 9 vertices and 25 edges that a vertex index requires 4 bytes, a pointer requires 6 bytes, and edge weights require 2 bytes. Calculate the byte requirements for an adjacency matrix.

V^2 * edge_weight bytes 81*2 = 162

Assume for an undirected graph with 10 vertices and 20 edges that a vertex index requires 4 bytes, a pointer requires 5 bytes, and that edge weights require 2 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

V^2 * edge_weight bytes =(10^2)*2 =200

Assume for an undirected graph with 9 vertices and 12 edges that a vertex index requires 4 bytes, a pointer requires 4 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

V^2 * edge_weight bytes = 324

Assume for an undirected graph with 7 vertices and 17 edges that a vertex index requires 2 bytes, a pointer requires 6 bytes, and that edge weights require 4 bytes. Since the graph is undirected, each undirected edge is represented by two directed edges. Calculate the byte requirements for an adjacency matrix.

V^2 * edge_weight bytes = 192 49 * 4

As computers have become more powerful:

We have used that additional computing power to tackle more complex problems

When are you required to have a throws clause in the header?

When there is a checked exception type and the programmer does not handle the exception

In which case might the number of comparisons NOT be a good representation of the cost for a sorting algorithm? When there are lots of records When the CPU is really fast When the amount of available space is small When we are comparing strings of widely varying length

When we are comparing strings of widely varying length

In which case might the number of comparisons NOT be a good representation of the cost for a sorting algorithm? When we are comparing strings of widely varying length When the amount of available space is small When the CPU is really fast When there are lots of records

When we are comparing strings of widely varying length

Sometimes, the constant factors in an algorithm's runtime equation are more important thant its growth rate. When the problem is sorting, this can happen in which situation? -When the records are nearly sorted - When there are lots of records - When the records are nearly reverse sorted When the CPU is really fast When the amount of available space is small When we are sorting lots of small groups of records.

When we are sorting lots of small groups of records.

Sometimes, the constant factors in an algorithm's runtime equation are more important thant its growth rate. When the problem is sorting, this can happen in which situation? When we are sorting lots of small groups of records. When the amount of available space is small When the CPU is really fast When the records are nearly reverse sorted When there are lots of records When the records are nearly sorted

When we are sorting lots of small groups of records.

A range query is:

Where a record is returned if its relevant key value falls between a pair of values

A range query is: Where a record is returned if its unique identifier matches the search value Where a record is returned if its relevant key value falls between a pair of values Another name for any database query for a key value A way of efficiently locating the records in a database

Where a record is returned if its relevant key value falls between a pair of values

An exact-match query is:

Where a record is returned if its unique identifier matches the search value

An exact-match query is: Where a record is returned if its relevant key value falls within a specified range Where a record is returned if its unique identifier matches the search value Another name for any database query that returns a key value A way of efficiently locating the records in a database

Where a record is returned if its unique identifier matches the search value

advantages of queue

While queues are more complex than stacks, the array makes queues easy by placing the newest element at the end and moving each element over one step when one piece of data is removed from the queue. Queues are helpful when multiple consumers share a particular process.

In which cases are the growth rates the same for Insertion Sort?

Worst and Average only

If you double the size of a hash table, can you keep using the same hash function?

Yes, but you will not hash to the new slots

Static class(Java)

You cannot use the static keyword with a class unless it is an inner class. A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a static nested class does not have access to the instance variables and methods of the outer class. Syntax class MyOuter { static class Nested_Demo { } } Instantiating a static nested class is a bit different from instantiating an inner class. The following program shows how to use a static nested class. public class Outer { static class Nested_Demo { public void my_method() { System.out.println("This is my nested class"); } } public static void main(String args[]) { Outer.Nested_Demo nested = new Outer.Nested_Demo(); nested.my_method(); } }

_exit vs exit

_exit returns to kernel immediately, exit performs certain cleanup processing then returns to kernel both expect a integer arg (exit(0))

A data item is: a.) A member of a type b.) An object instantiated from a class c.) A specification of a type within some language d.) An implementation of an ADT

a

A range query is: a.) Where a record is returned if its relevant key value falls between a pair of values b.) Where a record is returned if its unique identifier matches the search value c.) A way of efficiently locating the records in a database d.) Another name for any database query for a key value

a

An exact-match query is: a.) Where a record is returned if its unique identifier matches the search value b.) A way of efficiently locating the records in a database c.) Where a record is returned if its relevant key value falls within a specified range d.) Another name for any database query that returns a key value

a

In computer science a metaphor is: a.) A label applied to a group of concepts b.) A comparison that does not use the word 'like' c.) The model of a type d.) A figure of speech in which a phrase is applied to an object to which it is not literally applicable

a

Explain why recursive linked list methods should not be made public

a Node references are passed as parameters to functions, the Node is an implementation details that should not be made public

What is a bit?

a binary digit

What do static members belong to?

a class/they are part of a class

hard drive

a collection of hardware that manipulates data on a particular type of storage device

What is a list

a collection that stores its elements in a position-based sequence

to easily move from any node to its successor, and from any node to its predecessor, and from the first to the last node and from the last to the first node you need

a double and circularly-linked list

network

a group of two or more computer systems linked together

jQuery

a library of JavaScript programs designed for easy integration onto a webpage

what is a stack trace?

a list of all the methods in the call stack, it indicates the method that was executing when an exception occurred and all of the methods that were called in order to execute that method

VPN (Virtual Private Network)

a network that uses a public telecommunication infrastructure, such as the Internet, to provide remote offices or individual users with secure access to their organization's network

Compiler

a program that translates source code into executable form. during the translation process, the compiler uncovers any syntax errors that may be in the program

Polymorphism

a reference variable of a superclass type can reference subclass objects

Exception Handler

a section of code that responds to exceptions when they are thrown

string

a string is an array of characters terminated with a null character \0

Spoofing

a technique intruders use to make their network or internet transmission appear legitimate to a victim computer or network

Assume that an array consists of at least 10 elements. The worst case time (in the big-oh sense) occurs in linear search algorithm when a. Item is not in the array at all b. Item is somewhere in the middle of the array c. Item is the first element in the array d. Item is the 1000th element of the array e. Item is the 10th element in the array f. Item is the last element in the array

a. Item is not in the array at all b. Item is somewhere in the middle of the array f. Item is the last element in the array

multi-catch

ability to catch multiple types of exceptions with a single catch clause (introduced in Java 7) Ex.) catch (FileNotFoundException | InputMismatchException ex) { System.out.println("Error processing the file."); }

fully buffered

actual I/O takes place when the standard I/O buffer is filled. We can call fflush(3) at any time to flush a stream.

What does the following statement do: Node p = new Node("Allan", myList);

adds a new node to the beginning of the list of elements already accumulated (uses the arg constructor that allows the successor of a node to be specified)

When does the code in a finally block execute?

after the try block has executed and after any catch blocks have executed if an exception was thrown

printStackTrace

all exception classes inherit this method from the Throwable class, it can be used to print a stack trace

calloc()

allocates space for a specified number of objects of a specified size

Array based lists are a contiguous allocation

allocates storage for list elements in consecutive memory locations

What is a linked list?

an implementation of a list in which elements are stored in nodes and each node contains a link to its successor

inode

an inode is information contained within a Unix system that contains details about each file or directory, such as the node, owner, file, location of file, etc. each inode stores the attributes and disk block locations of the objects data. directories are lists of names assigned to inodes. a directory contains an entry for itself, its parent, and each of its children.

process

an instance of a running program

What is an object?

an object is an instance of a class

data structure

any data representation and its associated operations -or- an organization or structuring for a collection of data items

char **argv

argv: pointer to array of pointers, to char

An ADT is most like which of the following? a.) A class b.) An interface c.) A program d.) An object e.) A method f.) A data structure

b

Which is NOT a topic that OpenDSA focuses on? a.) How to measure the effectiveness of a data structure or algorithm b.) How to design and maintain large programs c.) The commonly used data structures d.) Introduce the idea of tradeoffs and reinforce the concept that there are costs and benefits associated with every data structure

b

Which is an example of a composite type? a.) An integer b.) A bank account record c.) A character d.) A floating point number

b

Which of these is NOT a definition for efficiency in a computer program? a.) It solves the problem within the required resource contraints b.) It runs in linear time c.) It requires fewer resources than known alternatives

b

Which of these is NOT one of the three standard steps to follow when selecting a data structure to solve a problem? a.) Select the data structure that best meets the requirements determined in the prior steps of the process b.) Run simulations to quantify the expected running time of the program c.) Quantify the resource constraints for each operation d.) Analyze your problem to determine the basic operations that must be supported

b

Which of these is more a concern for Software Engineering than for a data structures course? a.) To design an algorithm that makes efficient use of the computer's resources b.) To design an algorithm that is easy to understand, code, and debug

b

bt

backtrace, shows you what series of function calls have led you to the current point in program (using letters in lphabetical order)

why standard i/o is considered more efficient

bc it has it's own predefined buffer within the struct that is used to store data so when you want the contents, you don't have to go to the kernel everytime

fread, fwrite

binary stream input/output

Primitive Data Types for Numeric Data:

byte, short, int, long, float, double

A type is: a.) A variable b.) Another name for an ADT c.) A collection of values d.) An integer e.) An implementation

c

(Recall that MM refers to the size of a hash table.) A hash function must: a.) Return a value betwen 1 and MM b.) Return values in equal distribution throughout the table c.) Return a value between 0 and M-1M−1 d.) Return the hash value for the key

c.) Return a value between 0 and M-1M−1

Which of these is NOT one of the three standard steps to follow when selecting a data structure to solve a problem? a.) Analyze your problem to determine the basic operations that must be supported b.) Quantify the resource constraints for each operation c.) Run simulations to quantify the expected running time of the program d.) Select the data structure that best meets the requirements determined in the prior steps of the process

c.) Run simulations to quantify the expected running time of the program

Internal list of all the methods currently executing

call stack

atexit(3)

calls handler functions in reverse order of their registration, each function is called as many times as it was registered

adding an element e in one step to a singly-linked list just before a node referenced by ref ...

can only be done when ref is the last node in the list

declaring a string

char s[5]; char c[] = "abcd"; char c[50] = "abcd"; char c[] = {'a', 'b', 'c', 'd', '\0'};

two categories of exceptions

check and unchecked

BIC.W #0x03, r5

clear bits in destination using .not.src.and.dst

Stack

collection of items that allows addition and removal of items in a last-in first-out manner

Queue

collection of items that is accessed in a first-in first-out manner

STDERR_FILENO

constant defined in <unist.h> header Standard error value, stderr. Its value is 2.

STDIN_FILENO

constant defined in <unist.h> header Standard input value, stdin. Its value is 0.

STDOUT_FILENO

constant defined in <unist.h> header Standard output value, stdout. Its value is 1.

What are the two ways to allocate storage for the elements of a list?

contiguous allocation and linked allocation

What do you have to do first before using an instance method?

create an instance of the class

A simple type is: a.) A subset of a type b.) The simplest type in a class c.) The model of a type d.) A type that cannot be broken down into smaller types

d

A tool for measuring the efficiency of an algorithm or problem is: a.) The system clock b.) Empirical analysis c.) A profiler d.) Algorithm analysis

d

Which is an example of a composite type? a.) A character b.) A bank account record c.) A floating point number d.) An integer

d.) a bank account record

c pointer syntax

data_type *var_name; EXAMPLE: int *p;

Beginning address for flash/ROM

depends on amount of ROM present

TCP

divides the data(coming from the application layer) into proper sized chunks and then passes these chunks onto the network. It acknowledges received packets, waits for the acknowledgments of the packets it sent and sets timeout to resend the packets if acknowledgements are not received in time. The term 'reliable connection' is used where it is not desired to loose any information that is being transferred over the network through this connection. So, the protocol used for this type of connection must provide the mechanism to achieve this desired characteristic. For example, while downloading a file, it is not desired to loose any information(bytes) as it may lead to corruption of downloaded content.

A data structure is: a.) Another name for an ADT b.) A specification for an implementation c.) A type d.) A collection of values e.) The implementation for an ADT

e

An ADT is a form of: a.) Simile b.) Metaphor c.) Design d.) Programming e.) Abstraction

e

fchmod()

evaluates pathname relative to open directory referenced by the fd argument

x/hx 0x3fe

examine the contents of memory

Hash tables provide...

extremely fast exact-match search. A record can be modified quickly as long as it does not affect its space requirements.

Big O

f(n) ∈ O(g(n)) if there exists c, n0 > 0 such that f(n) ≤ c*g(n) for all n ≥ n0

Big Omega

f(n) ∈ Ω(g(n)) if there exists c, n0 > 0 such that f(n) ≥ c*g(n) for all n ≥ n0

Determine the proper relationship between the following pair of functions. f(n)=logn^2 g(n)=(logn)^2 f(n)is O(g(n)) f(n) is Θ(g(n)) f(n)is in Ω(g(n))

f(n)is O(g(n))

A problem maps inputs to outputs. True False

false

if you want to get a full line, which function you should use in standard I/O

fgets()

Binary File

file that contains raw binary data

One or more statements always executed after the try block and the catch block have executed

finally block

free()

frees the memory space pointed to by ptr must have been returned by a previous call to malloc(), calloc() or realloc(). If free(ptr) has already been called before, undefined behavior occurs. If ptr is NULL, no operation is performed.

Take the following list of functions and arrange them in ascending order of growth rate. That is, if function g(n) immediately follows function f(n) in your list, then it should be the case that f(n) is O(g(n)). g1(n) = 2n g2(n) = n4/3 g3(n) = n(log n)3 g4(n) = nlog n g5(n) = 22n g6(n) = 2n2

g3(n) = n(log n)3 g2(n) = n4/3 g4(n) = nlog n g1(n) = 2n g6(n) = 2n2 g5(n) = 22n

generic class or method

generic class or methods permit you to specify the allowable types of objects that the class or method may work with

&r7

go to absolute address of r7 to grab data

how are memory leaks caused

if you don't use free() after using malloc() or calloc() (memory is set aside and cannot be used for other processes)

Where are parity bits for Hamming Code place?

in data bits at places like 2^n where n>= 0

realloc()

increases or decreases size of a previously allocated area. only increases if there is available memory behind it on the heap.

symbolic link

indirect pointer to a file special kind of file that points to another file does not contain the data in the target file

What does the throws clause do?

informs the compiler of the exceptions that could get thrown from a method

offset()

integer indicating the distance (displacement) between the beginning of the object and a given element or point, presumably within the same object.

what is a call stack?

internal list of all the methods that are currently executing

valgrind

is a memory mismanagement detector. It shows you memory leaks, deallocation errors, etc.

Asymptotic algorithm analysis

is an analytic tool, whereby we model the key aspects of an algorithm to determine the growth rate of the algorithm as the input size grows. It has proved hugely practical, guiding developers to use more efficient algorithms. But it is really an estimation technique, and it has its limitations.

What does it mean to "throw" an exception?

it means to generate an exception object specific to the error or unexpected event

What does a file with the extension .java contain?

java source code

a method for removing the element at an index k in a list throws an exception unless

k is non negative and less than the size of the list

the reference last points to the last node in a nonempty doubly-linked list, remove the last node from the list last

last = last.prev;

Add element e to the end of a doubly linked list with a pointer last pointing to the last node

last.next = new Node(e, null, last); last=last.next;

kernel

linux operating system

stack trace

list of all the methods in the call stack

C path

list of path prefixes to search for executable file

What does the statement if(object1 == object2) compare?

location in memory, not the data contained in the objects

lseek()

lseek() repositions the file offset of the open file description associated with the file descriptor fd to the argument offset according to the directive whence as follows:

ERROR handling for calloc()

make sure it doesn't return null

to allocate memory on heap, what functions must you use

malloc() or calloc()

Object Oriented Programming

method of software development that has its own practices, concepts, and vocabulary

when a class member is declared as protected, what code may access it?

methods in a subclass and by methods in the same package as the class

remove the first node of a nonempty, doubly-linked list myListmyList = myList.next;

myList = myList.next

In the worst case, the total number of comparisons for Insertion Sort is closest to:

n^2/2

argv[0]

name of file

For the simple string hash function that sums the ASCII values for the letters, does the order of the letters in the string affect the result?

no

does strlen include '\0'

no

8 ways for a process to terminate

normal termination - return from main - calling exit - calling _exit - returning the last thread from its start routine - calling pthread_exit from the last thread abnormal termination - calling abort - receipt of a signal - response of the last thread to a cancellation request

What do you have to do before calling a static method?

nothing, they can be called without an instance of the class created

What is the parent class of all classes

object

chmod()

operates on specified file used to modify the 9 permission bits (u -user, g -group, o -other) returns 0 if OK, -1 on error

hard link

points directly to the file (using i node)

hard link

points directly to the i-node of a file

argv[1]

points to first argument in command line

p var

print a variable in scope

p $r14

print the contents of a register

p[variable]

prints out value of variable given

info locals

prints out values of all local variables

Object serialization

process of converting an object to a series of bytes and saving them to a file

Deserialization

process of reconstructing a serialized object

What kind of exceptions does the RunTimeException class serve?

programming errors, such as an out-of-bounds array subscript

write a recursive method print(Node ref) that prints the values of all elements in the linked list whose first node is ref

public void print(Node ref) if(ref != null) { System.out.print(Ref.value+ " "); ref = ref.next; } }

q

quits GDB

binary I/O

read an entire structure at a time

gets()

reads until '\n' - and reads/stores \n (read a line of string.) And, you can use puts() to display the string.

To add an element e just after a node referenced by ref. you should use the statement:

ref.next = new Node(e, ref.next);

heap

region in your computer's memory that is not managed automatically for you - variables can be accessed globally - no limit on memory size - slower access - no guaranteed efficient use of space, memory may become fragmented over time as blocks of memory are allocated, then freed - variables can be resized using realloc()

int fork(void)

returns 0 to the child process, child's PID to parent process child is almost identical to parent: - child gets an identical (but separate) copy of the parent's virtual address space - child gets identical copies of the parent's open file descriptors - child has a different PID than the parent

return value of realloc()

returns a pointer to the newly allocated memory suitably aligned for any kind of variable and may be different from ptr, or NULL if the request fails or if size was equal to 0. If realloc() fails the original block is left untouched - it is not freed or moved.

return value of free()

returns no value

Three states if processes

running - process us either executing, or waiting to be executed and will eventually be chosen to execute by the kernel stopped - process execution is suspended and will not be scheduled until further notice terminated - process is stopped permanently

buffer pool

serves as the database server's shared cache memory area (once a sector is read, its information is stored in main memory. This is known as buffering or caching the information)

b *0xc000

set a breakpoint at a memory address

b func

set a breakpoint on a function

b main.c:10

set a breakpoint on a number

Procedural programming

set of statements that together perform a certain task

b or break

sets a breakpoint ex: b main --> sets a breakpoint at point

file descriptor

small, non-negative integer which identifies a file to the kernel.

open-closed principle

software entities should be open for extension, yet close for modification.

shell

special application that provides an interface for running other applications.

stack

special region of your computer's memory that stores temporary variables created by each function (LIFO) - grows and shrinks as functions push and pop variables - has size limits - variables only exist while the function that created them is running

absolute path

specifies the location of a file or directory from the root directory(/) using the complete path from start file. example: cat /home/kt/abc.sql

run arg1 arg2

start program with arguments

How does linked allocation store list elements?

stores a pointer to the memory location of its successor Ex.) linked lists

Variables

symbolic names made up by the programmer that represent locations in the computer's RAM

traversal of a collection

systematic method of doing some processing at each element of the collection

Hamming code

technique used for error detection and correction - detects single bit errors only

void exit(int status)

terminated with an exit status of 'status' normal return status is 0, nonzero on error

BIT.W #0x08, R5

test bits in destination using AND operation

GDB

the GNU debugger

if X is a list element with index k, then its successor is ___________and its predecessor is ____________

the element with index k+1; the element with index k-1

CPU

the hardware that controls execution of computer instructions

A data structure is: - A specification for an implementation - Another name for an ADT - A type - The implementation for an ADT - A collection of values

the implementation for an ADT

Data structure

the implementation for an ADT.

To remove a node that is not the head of a singly-linked list conveniently, you need to have a reference to

the node that precedes it

A sorting algorithm is said to be stable if it does not change......

the relative ordering of records with identical key values

Abstract data type (ADT)

the specification of a data type within some language, independent of an implementation. The behavior of each operation is determined by its inputs and outputs. An ADT does not specify how the data type is implemented. These implementation details are hidden from the user of the ADT and protected from outside access, a concept referred ti as encapsulation.

unbuffered

the standarad I/O library does not buffer the characters

Difference between a throws statement and a throws clause

the throw statement causes an exception to be thrown, the throws clause informs the compiler that a method throws one or more exceptions

content of a normal c variable

the value of variable

return value of calloc() and malloc()

the value returned is a pointer to the allocated memory, which is suitably aligned for any kind of variable, or NULL if the request fails.

What do instance methods do?

they perform an operation on a specific instance of the class. Ex.) box.getLength(); //you call the method on that one instance of the class, names box in this example

You use this statement to throw an exception manually

throw

FileNotFoundException

thrown when an application tries to open a file that does not exist

EOFException

thrown when an application tries to read beyond the end of a file

PrintWriter

to open a file for writing

goal of buffering

to use the minimum number of read(2) and write(2) calls

breadth first order

top to bottom (starts at root and then explores all next level nodes before moving on to the next depth level)

A subclass reference variable can reference a subclass object, T or F

true, a class can point to itself

5 keywords related to Exception Handling

try catch throw throws finally

3 combination of try-catch-finally

try-catch try-finally try-catch-finally

how many times is fork returned from one call?

twice, the only way to differentiate if it is the parent or child process getting returned is by PID

@r7

use contents of r7 as an address to move data

How do you retrieve the default error message?

use the Exceptions getMessage() method (every exception class has one) by putting exceptionVariableName.getMessage())

fork()

used by a process to create another process. parent - process that used fork() child- process created by parent You can tell which is which by checking the return value from fork(). Parent gets the child's pid returned Child gets 0 returned (if newly created) If fork() returns a negative value, the creation of a child process was unsuccessful. #include <sys/types.h> #include <unistd.h> #include <stdio.h> pid_t fork(void); void main(void) { pid_t pid; switch (pid = fork()) { case -1: /* Here pid is -1, the fork failed */ /* Some possible reasons are that you're */ /* out of process slots or virtual memory */ perror("The fork failed!"); break; case 0: /* pid of zero is the child */ /* Child can call getpid() to obtain its pid */ default: /* pid greater than zero is parent getting the child's pid */ printf("Child's pid is %d\n",pid); } }

. vs ..

used for relative pathnames: - . is current directory - .. represents the parent directory

malloc

used to allocate memory when you don't know the size. malloc function allocates size bytes and returns a pointer to the allocated memory. The memory is not initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be success fully passed to free().

relative path

uses either the current or parent directory as reference and specifies the path relative to it. uses one of these cryptic symbols: . or ..

What are primitive type variables?

variables that hold the data items that they are associated with

What are class type variables?

variables that hold the memory address of the data item it is associated with. Ex.) If a variable called "name" is a String class variable, then name can hold the memory address of a String object. (variable points to its location in memory/references the object)

What is inheritance?

when classes are derived from other classes, thereby inheriting fields and methods from those classes. inheritance allows you to extend the capabilities of a class by creating another class that is a specialized version of it

fchmodat()

when the AT_SYMLINK_NOFOLLOw flag is set, it doesn't follow symbolic links

n

will step forward one block of code(until next function call)

s

will step forward one line of code

what permissions do you need to create/delete a file?

write and execute permission in the directory, do NOT need read or write permission for the file itself

does strcpy inclue '\0'

yes

What is the running time of Insertion Sort when the input is an array that has already been sorted?

Θ(n)

Given an array-based list implementation, deleting the current element takes how long in the average case? \Theta(\log n)Θ(logn) time \Theta(n)Θ(n) time \Theta(n \log n)Θ(nlogn) time \Theta(1)Θ(1) time

Θ(n) time

Given an array-based list implementation, inserting a new element takes how long in the average case?

Θ(n) time

Given an array-based list implementation, inserting a new element to the current position takes how long in the average case? \Theta(n)Θ(n) time \Theta(n \log n)Θ(nlogn) time \Theta(1)Θ(1) time \Theta(\log n)Θ(logn) time

Θ(n) time


Kaugnay na mga set ng pag-aaral

GS - MGT 303 CH 1 Professional Communication in a Digital, Social, Mobile World

View Set

Global Warming and Sea Level Rise

View Set

Chapter 52 - Assessment of the GI System

View Set

Anatomy and Physiology multiple choice 1

View Set