Object Oriented Programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How do you search for a target key in a linked list?

-Have to apply sequential search -Each node is traversed and compared with the target key and if it is different, then follows the link to the next node -Continues until target key is found or if the last node is reached

Do all declaration statements result in a fixed reservation in memory?

-Most declarations do, with the exemption of pointers -Actual memory allocation for eh data comes during run-time

New vs. Override

-New modifier instructs the compiler to user the new implementation instead of the base class function -override modifier helps to override the base class function

Fibonacci Search

-Search algorithm that applies to a sorted array -makes use of divide and conquer approach that can significantly reduce the time needed in order to reach the target element

Explain binary search tree

-Stores data in such a way that they can be retrieved very efficiently -Left subtree contains nodes whose keys are less than the node's key value while the right subtree contains nodes whose keys are greater than or equal to the node's key value

What is an abstract class?

-They are used to declare common characteristics of subclasses. An abstract class cannot be instantiated, only extended. Abstract classes are declared with the "abstract" keyword. Can have both implemented and abstract methods. -cannot be instantiated, creation of an object is not possible with abstract class but it can be inherited

What is merge sort?

-Uses divide and dequeue.If we have an array of 8 we divide it to 2 arrays of 4, then 4 of 2, then 8 of 1, and solve each individually and merge back together to 4 arrays of 2, then 2 arrays of 4, then 1 array of 8. The time complexity is O(nlogn), the space complexity is O(n) -divide and conquer strategy in which in a sequence of data, adjacent ones are merged and sorted to create bigger sorted lists and then the sorted lists are then merged again to form an even bigger sorted list

Ternary Operator

-an operator that takes three arguments -Its an if else (if true, then do this) Ex: string sex = "M" String gender = (sex =="M") ? "Male" : "Female";

What is a recursive algorithm?

-calls itself and targets a problem by dividing it into smaller, more manageable sub-problems -output of one recursion after processing one sub-problem becomes the input to the next process

What is the super keyword?

-invokes the overriden method which overrides one of its superclass methods -allows to access overridden methods and also to access hidden members of the superclass -forwards a call from a constructor to a constructor in the superclass

What are multidimensional arrays?

-multiple indexes to store data -useful when storing data that cannot be represented using single dimensional indexing, such as data representation in a board game

How do you deal with multisource problems?

-restructure of schemas to accomplish schema integration -identify similar records and merge them into single record with all relevant attributes redundancies

Huffman's algorithm

-used for creating extended binary trees that have minimum weighted path lengths from the given weights -makes use of a table that contains the frequency of occurrence for each data element

How many instances can be created for an abstract class?

0

What is the minimum number of nodes that a binary tree can have?

0 when NULL, 1-2 when not NULL

How do you insert a new item in a binary search tree?

1) Check first if the tree is empty, insert the new item in the root node, if not empty refer to the new item's key 2) If it's smaller than the root key, insert into left otherwise insert into the root's right

What are the missing patterns that are generally observed?

1) Missing completely at random 2) Missing at random 3) Missing that depends on the missing value itself 4) Missing that depends on unobserved input variables

K-Mean algorthim

1) Partititioning method 2)Objects classfiied as belonging to one of K groups, k chosen beforehad 3) clusters are spherical an data points in a cluster are centered around that cluster 4) variance/spread of the clusters is similar: each data point belongs to the closest cluster

What are the operators that cannot be overloaded?

1) Scope resolution (::) 2) Member selection (.) 3) Member selection through a pointer to function (.*)

What are best practices for data cleansing?

1) Sort by diff attributes 2)For large datasets, cleanse it stepwise and improve data each set 3) for large datasets, break them into small data because increases iteration speed 4)to handle common cleansing tasks, create a set of utility functions/tools/scripts 5) arrange them by estimating frequency and attack common problems 6)keep track of everything

What should be done with suspected or missing data?

1) prepare validation report 2) get smart bois to examine data 3) invalid data assigned and replaced with validation code 4) work on missing data

What are the steps in an analytics project?

1) problem definition 2) data exploration 3) data prep 4) modelling 5) validation 6) implementation and tracking

What is minimum number of queues needed when implementing a priority queue?

2

What is a class?

A blueprint that defines an objects variables and methods

What is a data structure?

A data structure is a data type whose components are smaller data structures and/or simple data types, related pieces of data in an organized manner

What is a dequeue?

A double ended queue, elements can be inserted or removed from either end

What is an inline function?

A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros, insert complete body of function wherever that function is used in the program source code and is like function substitution

What is a linked list?

A list of nodes or elements of a data connected by pointers

What is bubble sort?

A sorting algorithm that slowly "bubbles" its way to to the top of the list whether it be a minimum or maximum value, compares two and switches places

What is the stack?

A stack is a data structure with elements of the *SAME* type. Data elements of the *stack* data structure can only be accessed (stored or retrieved) at one end of the stack in a *LIFO* manner.

What is method overriding?

A subclass method has the same method signature as the superclass method, same method name, parameter, and same return type

What is data cleansing?

AKA data scrubbing - consists of activities for detecting and correcting data in a database that are incorrect, incomplete, improperly formatted or redundant

What are access modifiers?

Access modifiers determine the scope of the method or variables that can be accessed from other various objects or classes. There are 5 types of access modifiers , and they are as follows:. Private. Protected. Public. Friend. Protected Friend.

What are sealed modifiers?

Access modifiers where the methods cannot inherit it, can also be applied to properties, events, and methods -cannot be used to static members

Base Class, Sub Class, and Superclass

Base/super - generalized and root, parent Sub-class - inherits from one or more base classes

What are the different types of arguments?

Call by value: value passed will get modified inside the function and returns same value Call by reference: value passed will get modified both inside and outside the functions and returns same or different value

What is a hierarchical clustering algorithm?

Combines and divides existing groups, creating a hierarchical structure that showcases the order in which groups are divided or merged

What is function overloading?

Defining several functions with the same name with unique list of parameters is called as function overloading.

What are common problems DS face?

Duplicate entries, missing values, illegal values, common misspelling

What is early and late binding?

Early binding refers to assignment of values to variables during design time whereas late binding refers to assignment of values to variables during run time.

Where are data structures applied?

Essential in almost every aspect where data is involved, numerical analysis, operating system, AI, compiler design, database management, graphics, and statistical analysis

What is exception handling?

Exception Handling is a mechanism to handle runtime errors.It is mainly used to handle checked exceptions. (try, catch, throw keywords for exceptions)

What is the use of finalize method?

Finalize method helps to perform cleanup operations on the resources which are not currently used. Finalize method is protected , and it is accessible only through this class or by a derived class.

FIFO

First In, First Out.

How do signed and unsigned numbers affect memory?

For signed numbers, the first bit is used to indicate whether it is positive or negative (one bit short so the range 0 to 255 would be -128 to +127) and with unsigned numbers, all bits for that number (0-255)

What is a friend function?

Friend function is a friend of a class that is allowed to access to Public, private or protected data in that same class. If the function is defined outside the class cannot access such information. Friend can be declared anywhere in the class declaration, and it cannot be affected by access control keywords like private, public or protected.

What is the framework by Apache?

Hadoop and Map Reduce

What is the advantage of a heap over a stack?

Heap: more flex, memory space for heap is dynamic but can be slower

What is a basic algorithm for searching a binary search tree?

If the tree is empty, then target not in the tree and end search if tree not empty, target in the tree check target is in root if target not in root, check if smaller (left) bigger (right)

Which OOPS concept is used as reuse mechanism?

Inheritance

File Storage vs Structure Storage

Main Memory = structure storage File = Auxiliary structure that is not stored in main memory

What data structures are applied when dealing with a recursive function?

Makes use of the stack, so using LIFO, a call to recursive function saves the return address so knows how to return to the calling function after the call terminates

What are manipulators?

Manipulators are the functions which can be used in conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl and setw.

Structure vs class

N/A

NULL vs VOID

NULL : value, empty value VOID: data type identifier, identify pointers

What is the main difference between a class and an object?

Object is an instance of a class -hold multiple information, but classes don't have any information -definition of properties and functions can done in class and can be used by the object -class can have sub-classes -- objects don't have sub -objects

Keyword for overloading?

Operator

What is postfix expression?

Operator follows its operands; no need to group sub expressions in parenthesis or to consider precedence

What is operator overloading?

Operator overloading is a function where different operators are applied and depends on the arguments. Operator,-,* can be used to pass through the function , and it has their own precedence to execute.

What is a graph?

Ordered pairs (edges or arcs) and are used to connect nodes where data can be stored and retrieved

Overloading vs Overriding

Overloading is static binding: nothing but the same method with diff arguments and it may or may not return the equal value in the same class Overriding is dynamic binding: the same method names with the same arguments and return types associated with the class and its child class

What does the keyword "virtual" declare for a method?

Override the method

What is data mining vs profiling?

Profiling: it targets on the instance analysis of individual attributes, gives information on various attributes like value range, discrete value and their frequency, data type, etc. Mining: cluster analysis, detection of unusual records, dependencies, sequence discovery, relation holding between several attributes

What is the difference between a stack and an array?

Stack is LIFO and array is whatever

In what data structures are pointers applied?

Stack, queue, binary tree

Static vs. Non-Static

Static -for a class, don't create an instance -for a method, you can call method without creating an instance -singleton class/method Non-static -you have to create an instance to use the method

What is logistic regression?

Statistical method for examining a dataset in which there are one or more independent variables that defines an outcome

What is a dynamic data structure?

Structures that can expand and contract as a program runs, flexible in manipulating data because it can adjust according to the size of the data

What is "this" pointer?

THIS pointer refers to the current object of a class. THIS keyword is used as a pointer which differentiates between the current object with the global object. Basically, it refers to the current object.

KNN Imputation

The missing attribute values are imputed by using the attribute values most similar to the attribute values that are missing

What is selection sort for an array?

The smallest element is first located and switched with the element at index 0, placing the smallest element first and keeps repeating by bringing the smallest element to the front

What are the various types of constructors?

There are three various types of constructors , and they are as follows:. - Default Constructor - With no parameters. - Parametric Constructor - With Parameters. Create a new instance of a class and also passing arguments simultaneously. - Copy Constructor - Which creates a new object as a copy of an existing object.

What are tokens?

Token is recognized by a compiler and it cannot be broken down into component elements. Keywords, identifiers, constants, string literals and operators are examples of tokens. Even punctuation characters are also considered as tokens - Brackets, Commas, Braces and Parentheses.

What is a virtual function?

Virtual function is a member function of a class and its functionality can be overridden in its derived class. This function can be implemented by using a keyword called virtual, and it can be given during function declaration. Virtual function can be achieved in C++, and it can be achieved in C Language by using function pointers or pointers to function.

PUSH vs POP

Way data is stored and retrieved in a stack -push: denotes data being added to it and data being pushed into the stack -pop: denotes retrieval, topmost data being accessed

What are constructors?

a method used to initialize the state of an object, and it gets invoked at the time of object creation 1) same name as class 2) must have no return type

What is an AVL tree?

a self-balancing binary search tree

What are binary trees?

an extension of a linked list with 2 nodes, a left node and a right node and a root that structures data

What is an object?

an instance of a class having its own state, behavior, and ID

Are linked lists considered linear or nonlinear data structures?

based on access strategies: linear depends on where you intend to apply

What is a queue?

collection of data kept in the order it was collected. You can only add from the back and remove from the front (line at BestBuy)

What are data validation methods?

data screening and verification

Dynamic or run time polymorphism?

dynamic means you don't know the data type when writing the code and during run time it sets the data type

What is an ordered list?

each node's position in the list is determined by the value of its key component, key values form an increasing sequence as the list is traversed

What is a destructor?

function (much like constructor) which is called when the object is explicitly deleted by code, or when the object passes out of scope, which can happen when the program exits a function; has the same name as the class, but with a tilde prefix.

What are the parts of a linked list?

head, tail, nodes

LIFO

last-in, first out: describes the order of a stack and how data is accessed, stored, and retrieved

Differentiate linear from nonlinear data structures

linear: when data elements are adjacent to each other (arrays, linked lists, stack, and queues) nonlinear: when each data element can connect to more than 2 adjacent data elements (trees and graphs)

What is the primary advantage of a linked list?

modified easily, works regardless of how many elements in the list

Can a static method use non-static members?

no

Do constructors require a parameter?

no

What is the default access modifier in a class?

private

What is the difference between private, protected, and public?

private : only access in this class protected: if inherit, can use public: can access in any class

What is an interface?

setting the contract, no scope of the methods or class -if you inherit the class, you have to have these 3 things or however many things -have to IMPLEMENT an interface -collection of abstract methods -can use to implement multiple inheritances

Dynamic memory allocation help in managing data?

store simple structured data types, dynamic memory allocation can combine separately allocated structured blocks to form composite structures that expand and contract as needed

What is a doubly linked list?

traversal across data elements can be done in both directions, 2 links in every node an done that links to the net node and another one that connects to the previous node

What is an outlier?

univariate and multivariate

What is linear search?

uses a loop process to search for the target; starts at front then proceeds one term at a time; stop at target or when hit the end; sequential and compares with target key

When is binary search best applied?

when elements are in order or sorted, start in middle and split and search

How can you call the base method without creating an instance?

would be a static method, inherit from that class using base keyword from a derived class


Set pelajaran terkait

Health Unit 4 Test - Play It Safe!

View Set

Logic Conversion, Conversion by Limitation, Obversion, Contraposition

View Set

Chapter 25:The New Deal (1933-1939)

View Set

DMV NJ- Questions missed on the practice test- Part 1

View Set

Sentence transformation: Rewrite the sentence using the word given, use between 2 and 5 words

View Set

¿Adónde vas? (Where do you go?)

View Set

Intermediate Accounting Chapter 13, 14 & 15. Current Liabilities and contingencies. Long-term Liabilities. Stockholders' equity.

View Set