General CS Knowledge Flashcards

1
Q

What is O-O-P?

A

Object-Oriented-Programming: A programming paradigm based on the concept of objects and classes, which can contain data and code. Data being in the form of fields (e.g. attributes/properties). Code being the form of procedures (e.g. methods).
It is used to structure a piece of software program into simple, reusable pieces of code (classes) which are used to create individual instances of objects.
A feature of objects is that an objects own procedure can access and modify the data fields itself.
E.G. JavaScript, C++, Java, Python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a class? (oop)

A
A class is a defined structure to create an object.
Classes often represent broad categories (e.g. dog, cat) that share attributes (e.g. colour). The classes define what attributes an instance of this type will have but not the value.
Classes also contain functions (methods) that are only available to objects of that type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an object? (oop)

A

An object is an abstract data type. An object has a state (data/fields/vars) and behaviour (code/methods). It can contain multiple properties and methods, even other objects.
In most programming languages objects are defined as classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a programming paradigm and what are the 4 main types?

A

A way to classify programming languages based on their features:

  • functional programming
  • Logical programming
  • object-oriented programming
  • Imperative programming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Imperative Programming paradigm?

A

The imperative programming paradigm assumes that the computer can maintain through environments of variables, any changes in a computation process. Computations are performed through a guided sequence of steps, in which these variables are referred to or changed. The order of the steps is crucial, because the given step with have different consequences depending on the current value of variables when the step is executed.
The imperative paradigm is popular because it closely resembles the machine itself.

Pros:

  • efficient
  • close to the machine
  • popular
  • familiar

Cons:

  • the semantics of a program can be complex to understand or prove because of referential transparency doesn’t hold (due to side affects)
  • side effects make debugging harder
  • abstraction is more limited that with some paradigms
  • order is crucial, which doesn’t always suit itself to problems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Logical Programming paradigm?

A

The logical paradigm takes a declarative approach to problem solving. Various logical assertions about the situation are made, establishing all know facts. Then queries are made. The role of the computer becomes maintaining data and logical deduction.

A logical program is divided into 3 sections:
1 - a series of definitions/declarations that define the problem domain
2 - statements of relevant facts
3 - statement of goals in the form of a query
Any deducible solution to a query is returned.The definitions and declarations are constructed entirely from relations.

Pros (bifold):

  • the system solves the problem, so the programming steps are kept to a minimum
  • proving validity of a given program is simple
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Functional Programming paradigm?

A

The functional programming paradigm views all sub-programs are functions in the mathematical sense informally - they take in arguments and return a single solution. The solution returned is based entirely on input, the time at which the function has been called has no relevance.

Languages - functional languages are created based on the functional paradigm. Such languages permit functional solutions to problems by permitting a programmer to to treat functions as first class objects (they can be treated as data and assumed to have the value of what they return; therefore they can be passed to other functions as arguments or returned from functions).

Pros (or functional lang)

  • the high level of abstraction, especially when functions are used, suppresses many of the details of programming and thus removes the possibility of committing many classes of error.
  • the lack of dependence on assignment operations, allowing programs to be evaluated in many different orders. This evaluation order independence makes function-oriented languages good for programming massively parallel computers.
  • the absence of assignment operations makes the function-orientated programs much more amenable to mathematical proof and analysis than imperative programs, because functional programs possess referential transparency.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the Object-Orientated Programming features and benefits?

A

OOP is a paradigm in which real world objects are viewed as seperate entities having their own state which is modified only by built in procedures (methods).
Because objects operate independently, they are encapsulated into modules which contain both local environments and methods. Communication with an object is done via message passing.

Objects are organised into classes, from which they inherit methods and equivalent variables. The o-o paradigm provides key benefits of code re-usability and extensibility.

Features + Benefits:

  • a new class (called a derived class or a subclass) may be derived from another class (called a base class or super class) by a mechanism called inheritence. The derived class inherits all the features of the base class; its structure and behaviour(repsonse to messages). In addition, the derived class may include additional states (instance variables), and may exhibit additional behaviour (new method to respond to new message). The derived class can also override behaviour corresponding to some of the methods of base class: there would be a different method to respond to the same message. The inheritance method is allowed even without access to the source code of the base class.
  • The ability to use inheritance is the single most distinguishable feature of the o-o paradigm. Inheritance gives OOP its chief benefit over other programming paradigms - relatively easy code reuse and extension without the need to change existing source code.
  • The mechanism of modelling a program as a collection of objects of various classes and futhermore describing many classes as extensions or modifications of other classes provides a high degree of modularity.
  • Ideally the state of an object is manipulated and accessed only by that objects methods. (Most o-o languages allow direct manipulation of the state, but such access is stylistically discouraged). In this way a class interface (how objects of that class are accessed) is separate from the class’ implementation (the actual code of the class’ methods). Thus encapsulation and information hiding are inherent benefits of OOP.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is two way data binding and one way data flow and how are they different?

A

Two way data binding meaning the UI fields are bound to model data dynamically, such that when the UI field changes, the model data changes with it and vice-versa. Angular is a popular framework that uses 2-way-binding.

One way data flow means that the model is the single source of truth. Changes in the UI trigger messages that signal user intent to the model (or ‘store’ in react). Only the model has access to change the apps state.
The effect is that data always flows in a single direction, making it easier to understand. React uses one way data flow, cycle.js is another uni-directional flow example.

One way data flows are deterministic, where as two way data binding causes side-affects which are harder to understand/follow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a monolithic architecture? pros/cons

A

A monolithic architecture means your app is written in one cohesive unit of code, whose components are designed to work together, sharing the same memory space and resources.

Pros:

  • Most apps typically have a large number of cross cutting concerns e.g. logging, rate limiting, security features such as audit trails and DOS protection.
  • When everything is running through the same app, it’s easy to hook up components with those cross cutting concerns.
  • There can also be performance advantages since shared memory access is faster than IPC (inter-process communication)

Cons:

  • Monolithic app services tend to get tightly coupled and entangled as the application evolves, making it difficult to isolate services for purposes such as scaling or code maintainability.
  • Monolithic architectures are harder to understand because there may be dependencies, side affects and magic which are not obvious when you are looking at a particular service or controller
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a micro service architecture? pros/cons

A

A micro service architecture means you app is made up of lots of smaller, independent applications capable of running their own memory space and scaling independently from each other across potentially many separate machines.

Pros:

  • typically better organised since each micro service has a very specific job and not concerned with the jobs of other components. Decoupled services are also easier to recompose and reconfigure to serve the purposes of different apps
  • they can have performance advantages depending on how they are organised because its possible to isolate hot services and scale them independent of the rest of the app.
  • tend to scale better

Cons:
-if your building a new micro service architecture, your likely to discover lots of cross cutting concerns that you did not anticipate at design time. A monolithic app could establish shared magic helpers or middleware to handle such cross cutting concerns without much effort.
-in a micro service architecture, you’ll need to incur the overhead of separate modules for each cross-cutting concern, or encapsulate cross-cutting concerns in another service layer that all traffic gets routed through.
Eventually even a monolithic architectures tend to route traffic through an outer service layer for cross-cutting concerns. But with a monolithic architecture it’s possible to delay the cost of the work until the project is much more mature
-micro services are frequently deployed on their own virtual machines or containers, causing a proliferation of VM wrangling work. These tasks are frequently automated with container fleet management tools.
-higher initial cost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is asynchronous programming and why is it important in JavaScript?

A

Synchronous programming means that, barring conditional and function calls, code is executed sequentially from top to bottom, blocking on long running tasks such as network requests and disk I/O.

Asynchronous programming means that the engine runs in an event loop. When a blocking operation is needed, the request is started, and the code keeps running without blocking the result. When the response is ready, an interrupt is fired, which causes an event handler to be run, where the control flow continues. This way a single program thread can handle many concurrent operations.

User interfaces are asynchronous by nature and spend most of their time waiting for user input to interrupt the event loop and trigger event handlers.
Node is asynchronous by default, meaning that the server works in much the same way, waiting in a loop for a network request, and accepting more incoming requests while the first one is being handled.

This is important in JavaScript because it is a very natural fit for user interface code, and very beneficial to performance on server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a closure?

A

A closure is the combination of a function bundled together with references to its surrounding state (the lexical environment). A closure gives you access to an outer functions scope from an inner function. In JavaScript closures are created every time a function is created.

To use a closure, define a function inside another function and expose it. To expose it, return or pass it to another function.

The inner function will have access to variables in the outer function scope, even after the outer function has returned.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Using closures (examples)…

A
  • commonly used to give people data privacy
  • In JavaScript, closures are the primary mechanism used to enable data privacy. When you use closures for data privacy, the enclosed variables are only in scope within the containing outer function. You can’t get at the data from an outside scope except through the objects privileged methods.In JavaScript, any exposed method defined within the closure scope is privileged.
  • Closures can also be used to create stateful functions, whose return values may be influenced by their internal state. e.g. const secret = msg => () => msg;
  • in functional programming, closures are also used for partial application and currying
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define Application

A

The process of applying a function to its arguments in order to produce a return value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define Partial Application

A

The process of applying a function to some of its arguments. The partially applied function gets returned for later use. Partial application fixes (partially applies the function to) one or more arguments inside the returned function, and the returned function takes the remaining parameters as arguments in order to complete the function application.
Partial application takes advantage of closure scope in order to fix parameters. You can write a generic function that will partially apply arguments to the target function.

17
Q

What is a pure function?

A

A pure function is a function which, given the same input, will always return the same output. It produces no side affects. They return an output based on that input.

18
Q

What is mapping?

A

Produce some output based on given inputs. A function maps input values to output values. Pure functions are all about mapping.

19
Q

What is an IDE?

A

An integrated development environment is an application used to create software. An IDE normally consists of at least a source code editor, build automation tools and a debugger.

20
Q

What is a tree?

A

a tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes

21
Q

What is a list?

A

a list or sequence is an abstract data type that represents a countable number of ordered values, where the same value may occur more than once

22
Q

What is an array list? +complexity

A

An array list is a dynamic array (self resizing). Expands as you add more elements.

Pros:

  • fast lookups O(1)
  • variable size
  • cache friendly (Just like arrays, dynamic arrays place items right next to each other in memory, making efficient use of caches.)

Cons:

  • slow worst case appends (usually takes O(1) but if theres no room and it has to expand it will take O(n) worst case.
  • costly inserts and deletes - elements are stored next to each other so inserting/removing an element in between requires move over elements O(n)
Complexity
add(element) → O(1)
remove(element) → O(n)
insert(element, index) → O(n)
get(index) → O(1)
23
Q

What is an array?

A

An array is a data structure that contains a group of elements ordered sequentially. Each position in the array has an index, starting at 0. Static arrays are not resizeable.

Pros:

  • fast lookups O(1)
  • fast append O(1) -adding to the end of array

Cons:

  • fixed size
  • costly insert/deletes - have to move over elements worst case O(n)
24
Q

What is a linked list?

A

A linked list organizes items sequentially, with each item storing a pointer to the next one. An item in a linked list is called a node. The first node is called the head. The last node is called the tail.

Pros:

  • adding elements on either end of the linked list is fast O(1)
  • flexible size

Cons:

  • costly lookups, worstcase O(n)
  • worstcase insert/delete is O(n)
25
Q

What is a queue?

A

A queue stores items in a first-in, first-out (FIFO) order.

Pros:
-all operations O(1) - fast

26
Q

What is a stack?

A

A stack stores items in a last-in, first-out (LIFO) order.
Pros:
-all operations O(1) - fast

27
Q

What is a hash table?

A

A hash table organizes data so you can quickly look up values for a given key.

Pros:

  • fast lookups on average O(1)
  • flexible keys- most data types can be used as long as their hashable

Cons:

  • bad worst cases - all O(n)
  • unordered
  • Single-directional lookups. While you can look up the value for a given key in O(1) time, looking up the keys for a given value requires looping through the whole dataset—O(n) time.
  • Not cache-friendly. Many hash table implementations use linked lists, which don’t put data next to each other in memory.
28
Q

What is a binary tree?

A

A binary search tree is a binary tree where the nodes are ordered in a specific way. For every node:

The nodes to the left are smaller than the current node.
The nodes to the right are larger than the current node.

Pros:

  • good performance across the board - assuming their balanced.
  • sorted

Cons:

  • bad performance if not balanced
  • no O(1) for anything
	Balanced	Unbalanced (Worst Case)
space	O(n) 	O(n)
insert	O(lg(n))	O(n)
lookup	O(lg(n))	O(n)
delete	O(lg(n))    O(n)
29
Q

What is a heap?

A

A binary heap is a binary tree where the smallest value is always at the top.

Pros:

  • quickly access the smallest item O(1)
  • Space efficient. Binary heaps are usually implemented with lists, saving the overhead cost of storing pointers to child nodes.

Cons:
-limited interface - finding small items is easy but larger items is harder O(n)

	               Worst Case
get min	        O(1)
remove min	O(lg(n))
insert	        O(lg(n))
heapify	        O(n)
space	        O(n)
30
Q

What is hashing?

A

A hash is a function that converts one value to another
A hash function can be used to generate a value that can only be decoded by looking up the value from a hash table. The table may be an array, database, or other data structure. A good cryptographic hash function is non-invertible, meaning it cannot be reverse engineered.

31
Q

What is a merge sort worst case?

A

O(nlogn)

32
Q

What is agile?

A

Agile is a term used to describe approaches to software development emphasizing incremental delivery, team collaboration, continual planning, and continual learning, instead of trying to deliver it all at once near the end.

33
Q

What is TDD?

A

Test Driven Development (TDD) is software development approach in which test cases are developed to specify and validate what the code will do. In simple terms, test cases for each functionality are created and tested first and if the test fails then the new code is written in order to pass the test and making code simple and bug-free.

34
Q

What is pair programming?

A

Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator,[1] reviews each line of code as it is typed in. The two programmers switch roles frequently.

35
Q

What is Rest API?

A

A RESTful API is an architectural style for an application program interface (API) that uses HTTP requests to access and use data. That data can be used to GET, PUT, POST and DELETE data types, which refers to the reading, updating, creating and deleting of operations concerning resources.

36
Q

What is cloud computing?

A

Cloud computing is the on-demand availability of computer system resources, especially data storage (cloud storage) and computing power, without direct active management by the user. The term is generally used to describe data centers available to many users over the Internet.[1] Large clouds, predominant today, often have functions distributed over multiple locations from central servers. If the connection to the user is relatively close, it may be designated an edge server.

37
Q

What’s the difference between int and long?

A

ints are 32-bit numbers, while longs are 64-bit numbers. This means ints take up half as much space in memory as longs, but it also means ints can’t store as big of numbers as longs.