
Pass Foundations-of-Computer-Science Exam - Real Test Engine PDF with 72 Questions
Get New Foundations-of-Computer-Science Certification Practice Test Questions Exam Dumps
NEW QUESTION # 14
What is the built-in data structure that implements a hash table in Python?
- A. Tuple
- B. List
- C. Dictionary
- D. Array
Answer: C
Explanation:
A hash table is a data structure that supports fast lookup, insertion, and deletion by using ahash functionto map keys to positions in an underlying storage structure. In Python, the built-in data structure that provides hash-table behavior is thedictionary, written with curly braces like {"a": 1, "b": 2}. Dictionaries store key- value pairs and are designed so that accessing a value by key, such as d["a"], is efficient on average.
Textbooks typically describe this expected efficiency as average-case constant time, often written as O(1), assuming a good hash function and a well-managed table size.
Tuples and lists are sequence types. Lists provide indexed access by integer position, not hashing by arbitrary keys. Tuples are immutable sequences and likewise do not provide key-based hashing semantics. "Array" is not the core built-in mapping structure in Python; while Python has an array module and NumPy has arrays, neither is the built-in hash table abstraction for general key-value storage.
Python dictionaries require keys to be hashable, meaning the key's hash value is stable during its lifetime (common examples: strings, numbers, tuples of hashable items). This requirement is directly tied to hash-table implementation. Dictionaries are used throughout computer science applications:
symbol tables in interpreters, caches and memoization, frequency counting, indexing, and implementing graphs via adjacency maps.
NEW QUESTION # 15
What is the alternative way to access the third element of the first row in np_2d?
- A. np_2d[2, 0]
- B. np_2d[0, 2]
- C. np_2d[1, 3]
- D. np_2d[3, 1]
Answer: B
Explanation:
NumPy arrays use zero-based indexing, meaning counting starts at 0 rather than 1. In a 2D NumPy array, indexing is typically written in the form array[row_index, column_index]. The first index selects the row, and the second index selects the column. Therefore, the "first row" corresponds to row index 0. Within that row, the "third element" corresponds to column index 2, because the columns are indexed 0, 1, 2, 3, and so on.
So, np_2d[0, 2] directly selects the element at row 0 and column 2, which is the third element in the first row.
This is considered an "alternative" to approaches like two-step indexing (np_2d[0][2]), and it is the standard idiom taught for multi-dimensional NumPy arrays.
The other choices point to different locations. np_2d[1, 3] is the fourth element of the second row, not the third element of the first row. np_2d[2, 0] and np_2d[3, 1] attempt to access the third or fourth row, which would often be out of bounds in a small 2-row example and would raise an IndexError. Correct indexing is a cornerstone of array programming because it determines which observation, feature, or matrix entry your computations will use.
NEW QUESTION # 16
Which Python command can be used to display the results of calculations?
- A. solve()
- B. result()
- C. print()
- D. compute()
Answer: C
Explanation:
In Python, the standard way to display output to the console is the built-in function print(). When a program performs calculations-such as arithmetic expressions, function results, or computed statistics-print() can be used to show those results to the user. For example, print(2 + 3) displays 5, and print(total / count) displays the computed average. Textbooks introduce print() early because it supports interactive learning, debugging, and communicating program behavior.
print() can display one or multiple items separated by commas, automatically converting them to string form.
It also supports formatting via f-strings (e.g., print(f"Sum = {s}")) and optional parameters like sep and end to control output formatting. This makes it versatile for reporting calculated values, intermediate steps in algorithms, and final program outputs.
The other options are not standard Python built-ins for output. compute(), result(), and solve() are not universally defined commands in Python; they might exist as user-defined functions or in specific libraries, but they are not the general command taught in textbooks for displaying results. Python follows a clear separation: expressions compute values; print() displays them.
Therefore, the correct answer is print(), as it is the primary mechanism for producing human-readable output from calculations in typical Python programs and coursework.
NEW QUESTION # 17
What is the correct way to represent a boolean value in Python?
- A. true
- B. True
- C. "True"
- D. "true"
Answer: B
Explanation:
Python has a built-in boolean type named bool, which has exactly two values: True and False. These are language keywords/constants and are case-sensitive. Therefore, the correct representation of a boolean value is True (capital T, lowercase rest) or False (capital F). This is consistently taught in introductory programming textbooks because it affects conditional statements (if, while), logical operations (and, or, not), and comparisons.
Option A, "True", is a string literal, not a boolean. While it visually resembles the boolean constant, it behaves differently: non-empty strings are "truthy" in conditions, but "True" == True is false because they are different types (str vs bool). Option B, "true", is also a string, and it differs in casing as well. Option D, true, is not valid in Python; it will raise a NameError unless a variable named true has been defined.
Textbooks also stress that boolean values often result from comparisons, such as x > 0, and that booleans are a subtype of integers in Python (True behaves like 1 and False like 0 in arithmetic contexts). Still, their primary use is representing logical truth values for control flow and decision- making.
NEW QUESTION # 18
What is a key advantage of using NumPy when handling large datasets?
- A. Automatic data cleaning
- B. Efficient storage and computation
- C. Interactive visualizations
- D. Built-in machine learning algorithms
Answer: B
Explanation:
NumPy's key advantage for large datasets isefficient storage and fast computation. Unlike Python lists, which store references to objects and can have per-element overhead, NumPy arrays store data in a compact, homogeneous format (single dtype) in contiguous or strided memory. This reduces memory usage and improves cache locality, which is crucial for performance on large arrays. Additionally, NumPy operations are vectorized: many computations run in optimized compiled code rather than interpreted Python loops. This enables large speedups for arithmetic, linear algebra, statistics, and transformations over entire arrays.
Option A is incorrect because NumPy itself does not provide full machine learning algorithms; those are typically found in libraries like scikit-learn, though they build on NumPy. Option B is incorrect because NumPy does not automatically clean data; data cleaning is usually done with pandas or custom logic. Option D is incorrect because interactive visualizations are typically handled by libraries like matplotlib, seaborn, or plotly, not by NumPy.
Textbooks in scientific computing highlight that NumPy forms the computational foundation of the Python data ecosystem. Its array model supports broadcasting, slicing, and efficient aggregations, all of which are essential when working with millions of numeric values. By combining compact memory layout with compiled numerical kernels, NumPy enables scalable analysis and simulation workloads that would be slow or memory-heavy using pure Python lists.
NEW QUESTION # 19
What statistical measure can be used to detect outliers in a dataset using NumPy?
- A. Median absolute deviation
- B. Variance
- C. Mode
- D. Standard deviation
Answer: A
Explanation:
Outlier detection often relies on measuring how far values deviate from a "typical" center. While variance and standard deviation can be used in simple z-score based methods, they arenot robust: a few extreme outliers can inflate the mean and standard deviation, masking the very outliers you want to find. A widely taught robust alternative is themedian absolute deviation (MAD), which is based on the median rather than the mean and therefore resists distortion by extreme values.
MAD is computed by first taking the median of the data, then computing the absolute deviation of each point from that median, and finally taking the median of those deviations. Because medians are stable under extreme values, MAD provides a strong baseline for identifying unusually distant points. Many textbooks and data analysis references present MAD as a robust scale estimator for outlier detection, often combined with a threshold rule such as flagging points whose deviation exceeds a constant multiple of MAD (with a scaling factor sometimes used to make it comparable to standard deviation under normality assumptions).
In NumPy, you can implement MAD using np.median() and np.abs(). Mode is generally not useful for continuous numeric outlier detection, and variance/standard deviation are more sensitive to outliers than MAD. Thus, among the given options, the best statistical measure for detecting outliers robustly is the median absolute deviation.
NEW QUESTION # 20
What is the layer of programming between the operating system and the hardware that allows the operating system to interact with it in a more independent and generalized manner?
- A. The file system layer
- B. The hardware abstraction layer
- C. The boot loader layer
- D. The task scheduler layer
Answer: B
Explanation:
TheHardware Abstraction Layer (HAL)is a software layer that sits between the operating system kernel and the physical hardware. Its purpose is to hide hardware-specific details behind a consistent interface, allowing the OS to be more portable and easier to maintain across different hardware platforms. Textbooks explain that without abstraction, the OS would need extensive device- and architecture-specific code scattered throughout the kernel, making updates and cross-platform support far more difficult.
The HAL typically provides standardized functions for interacting with low-level components such as interrupts, timers, memory mapping, and device I/O. With a HAL, the OS can call general routines (for example, to configure an interrupt controller) while the HAL handles the platform-specific implementation.
This supports a key systems principle: separate policy (what the OS wants to do) from mechanism (how hardware accomplishes it).
The other options are not correct. A boot loader runs at startup to load the operating system into memory; it is not the general interface layer during normal operation. The task scheduler is a kernel subsystem that manages CPU time among processes, not a hardware-independence layer. The file system layer manages storage organization and access semantics; it is not the general abstraction for all hardware interactions.
Therefore, the programming layer that enables generalized OS interaction with hardware is the hardware abstraction layer.
NEW QUESTION # 21
What is the time complexity of a quicksort algorithm?
- A. O(n)
- B. O(1)
- C. O(log n)
- D. O(n log n)
Answer: D
Explanation:
Quicksort is a divide-and-conquer sorting algorithm. It works by selecting a pivot element, partitioning the array into two subarrays (elements less than the pivot and elements greater than the pivot), and then recursively sorting those subarrays. In the average case, the partition step splits the array into roughly equal halves, so the recurrence is commonly written as (T(n) = T(n/2) + T(n/2) + O(n)), where (O(n)) is the cost of partitioning. This solves to (O(n \log n)), which is why quicksort is widely taught as an efficient general- purpose sorting method.
However, textbooks also emphasize that quicksort has a worst-case time complexity of (O(n^2)) when partitions are extremely unbalanced (for example, repeatedly choosing the smallest or largest element as the pivot on already sorted input). Practical implementations reduce the likelihood of worst-case behavior using randomized pivots or "median-of-three" pivot selection. Despite the worst-case, quicksort is often very fast in practice because it has good cache performance and low constant factors, and it sorts in place with only (O (\log n)) average recursion stack space.
Among the provided options, the correct expected complexity for quicksort (average-case, and commonly cited in coursework questions) is (O(n \log n)). The other options are too small to represent the cost of sorting arbitrary data.
NEW QUESTION # 22
What is traversal in the context of trees and graphs?
- A. The process of removing all nodes
- B. The process of visiting all nodes
- C. The process of changing the value of nodes
- D. The process of connecting all nodes
Answer: B
Explanation:
In data structures and algorithms,traversalrefers to systematicallyvisiting nodesin a tree or graph in order to process them. "Visiting" typically means performing some operation at each node, such as reading its value, marking it as seen, computing a property, or collecting it into an output structure. Traversal is foundational because many algorithms-search, path finding, connectivity checks, topological analysis, and evaluation of expressions-are built on traversal patterns.
Intrees, traversal has classic forms: preorder, inorder, and postorder depth-first traversals, as well as breadth- first traversal (level-order). Each defines a rule for the order in which nodes are visited relative to their children. Ingraphs, traversal must additionally handle the possibility of cycles and multiple paths; textbooks therefore emphasize maintaining a "visited" set to avoid infinite loops. The two principal graph traversal strategies areDepth-First Search (DFS)andBreadth-First Search (BFS). DFS explores along a path as far as possible before backtracking, while BFS explores layer by layer outward from a start node.
Options A, B, and C do not define traversal. Changing values may happen during traversal, but it is not what traversal means. Removing all nodes is deletion, not traversal. Connecting all nodes is not a standard traversal concept. The correct definition is the process of visiting all nodes (typically reachable from a starting node, or all nodes in the structure if fully connected).
NEW QUESTION # 23
Which protocol provides encryption while email messages are in transit?
- A. IMAP
- B. HTTP
- C. TLS
- D. FTP
Answer: C
Explanation:
"Encryption in transit" means protecting data while it moves across a network so that eavesdroppers cannot read or modify it. For email systems, this protection is most commonly provided byTLS (Transport Layer Security). TLS is a cryptographic protocol that can wrap application protocols (including mail protocols) to provide confidentiality, integrity, and server (and sometimes client) authentication. In practice, TLS is used to secure connections such as SMTP submission (often with STARTTLS or implicit TLS), IMAP over TLS, and POP3 over TLS. Textbooks present TLS as the standard successor to SSL and the foundation of secure communication on the modern Internet.
The other options are not correct in this context. FTP is a file transfer protocol and is traditionally unencrypted unless paired with additional security mechanisms (e.g., FTPS, which uses TLS, or SFTP, which uses SSH). HTTP is a web protocol; it becomes encrypted only when used as HTTPS, which again relies on TLS underneath. IMAP is an email retrieval protocol, butIMAP itself is not the encryption protocol- IMAP can be run over TLS (IMAPS) to become secure.
Therefore, the protocol that provides encryption while email messages (or email protocol traffic) are in transit is TLS.
NEW QUESTION # 24
What type of encryption is provided by encryption utilities built into the file system?
- A. Encryption at rest
- B. Encryption authentication
- C. Encryption in motion
- D. Encryption steganography
Answer: A
Explanation:
File system encryption utilities are designed to protect datastored on a disk-for example, files on an SSD, HDD, or other persistent storage. This protection is calledencryption at rest. The key idea is that if an attacker steals the physical drive, gains access to a powered-off machine, or otherwise reads storage directly, the raw bytes on disk remain unreadable without the correct cryptographic key. Common textbook examples include full-disk encryption and per-file encryption supported by operating systems and file systems.
This differs fromencryption in motion(also called encryption in transit), which protects data while it is being transmitted over networks, such as via TLS/HTTPS, VPNs, or secure messaging protocols. File system utilities do not primarily address network transmission; they address stored data confidentiality. Option B,
"encryption authentication," is not a standard category; authentication is a security goal often achieved using mechanisms like digital signatures, MACs, certificates, and protocol handshakes, not a type of file system encryption. Option D, steganography, is the practice of hiding information within other data (like images or audio) rather than encrypting it for confidentiality.
In short, file system encryption utilities aim to ensure that stored files remain confidential if storage is accessed without authorization, which is precisely the definition of encryption at rest.
NEW QUESTION # 25
print(20 # 5)
What will the output be of this line?
- A. no output
- B. Syntax Error
- C. #25
- D. 20 + 5
Answer: A
Explanation:
In Python, the # character begins acomment. Everything from # to the end of the line is ignored by the interpreter and is not executed. Therefore, the line # print(20 # 5) producesno outputbecause it is a comment, not an executable statement. This is a standard concept in programming language textbooks: comments are for humans, not for the machine, and they are used to document code, explain intent, temporarily disable statements during debugging, or leave notes about assumptions and design choices.
Even though the line contains an unusual symbol #, it does not matter here, because the interpreter never tries to parse the commented text. If the # were removed, then Python would attempt to parse print(20 # 5), and since # is not a valid Python operator, that would indeed trigger a syntax error. But with the leading #, the entire line is inert.
Option A is incorrect because nothing is evaluated. Option C is incorrect because comments are not printed; they remain only in the source code. Option D is incorrect for the commented version of the line, since Python does not check comment contents for syntax. Thus, the correct result is no output.
NEW QUESTION # 26
Which file system is commonly used in Windows and supports file permissions?
- A. HFS+
- B. NTFS
- C. EXT4
- D. FAT32
Answer: B
Explanation:
Windows commonly uses the NTFS (New Technology File System) for internal drives and many external drives because it supports advanced features required for modern operating systems. One of the most important features is support forfile and folder permissionsvia Access Control Lists (ACLs). Permissions enable the OS to enforce security policies by controlling which users and groups can read, write, execute, modify, or delete specific resources. This is fundamental to multi-user security and is a standard topic in operating systems and security textbooks.
FAT32 is an older file system designed for simplicity and broad compatibility. It does not provide the same fine-grained permission model as NTFS, which is why it is often used for removable media where cross- platform compatibility matters more than access control. HFS+ is historically associated with Apple's macOS systems, and EXT4 is widely used on Linux. While these file systems have their own permission and feature models, they are not the common Windows default for permission-managed storage in typical Windows deployments.
NTFS also supports journaling (improving reliability after crashes), large file sizes, quotas, compression, and encryption features (through Windows facilities). In enterprise environments, NTFS permissions integrate with Windows authentication and directory services, enabling centralized user management. Therefore, for Windows systems requiring file permissions, NTFS is the correct answer.
NEW QUESTION # 27
What is a correct call to the linear search defined as def linear_search(customersList, search_value): ?
- A. linear_search()(customersList)
- B. search_linear(customersList, search_value)
- C. find_linear(customersList)
- D. print(linear_search(customersList, search_value))
Answer: D
Explanation:
A function definition in Python specifies a function name and a list of parameters. Here, def linear_search (customersList, search_value): defines a function named linear_search that requirestwo argumentswhen called: a list (or sequence) of customer items and the value being searched for. A correct call must therefore supply both arguments in the same order: linear_search(customersList, search_value). Option B is correct because it calls the function properly and then prints the returned result.
Textbooks describe linear search as scanning the list from the beginning to the end, comparing each element to search_value until a match is found or the list ends. The function typically returns an index (e.g., position of the match) or a Boolean, or possibly -1/None if not found. Wrapping the call in print(...) is a standard way to display the returned value for testing or demonstration.
Option A is incorrect because it calls a different function name, not linear_search. Option C is incorrect because linear_search() would attempt to call the function with zero arguments, which would raise a TypeError, and then it tries to call the result as if it were another function. Option D uses a different function name (search_linear) and also contains a spelling mismatch compared to the given definition.
NEW QUESTION # 28
What stores the location of the next node in a linked list?
- A. The pointer
- B. The value
- C. The index
- D. The header
Answer: A
Explanation:
A linked list is a dynamic data structure made up of nodes, where each node typically contains two components: a data field (the value being stored) and a link field (commonly called a pointer or reference).
The pointer's role is to store the memory address (or reference) of the next node in the sequence, thereby maintaining the logical order of the list even though nodes may be scattered throughout memory. This is a key contrast with arrays, which store elements contiguously and rely on index arithmetic to locate the next element.
Because each node explicitly points to the next node, linked lists support efficient insertion and deletion operations compared with arrays. To insert a node, you allocate it and then adjust pointers so it fits into the chain. To delete a node, you redirect the pointer of the previous node to skip over the removed node.
Traversal is performed by starting at the head node and repeatedly following the pointer until a null reference indicates the end of the list.
The other options do not correctly describe what stores the location of the next node. An index is used in array-like structures, not in a standard linked list node. The value is the payload data, not the link.
The "header" (often called the head pointer) is an external reference to the first node, not the field inside each node that links to the next. Therefore, the correct answer is the pointer.
NEW QUESTION # 29
What are Python functions that belong to specific Python objects?
- A. Methods
- B. Libraries
- C. Modules
- D. Scripts
Answer: A
Explanation:
In object-oriented programming, amethodis a function that is associated with an object (or its class) and is called using the dot operator. In Python, everything is an object, and many operations are provided through methods. For example, "hello".upper() calls the upper method of a str object, and [1, 2, 3].append(4) calls the append method of a list object. Textbooks emphasize that methods operate on an object's internal state and typically receive the object itself as an implicit first argument (commonly named self in class definitions).
This is what distinguishes methods from standalone functions.
Modules, scripts, and libraries are different organizational concepts. Amoduleis a file containing Python code, including function and class definitions. Ascriptis a Python program intended to be run directly. A libraryis a collection of modules that provides reusable functionality. None of these terms specifically mean
"functions that belong to objects."
Understanding methods matters because it connects to encapsulation and abstraction: objects provide behaviors (methods) that manipulate their data in well-defined ways. This design enables clearer APIs and supports polymorphism, where different object types can expose methods with the same name but different implementations. In Python, method calls are central to working with built-in types (strings, lists, dictionaries) and with user-defined classes, making "methods" the correct term for functions that belong to specific objects.
NEW QUESTION # 30
What is the first step in the selection sort algorithm?
- A. Sort the list in descending order.
- B. Determine the lowest value starting from the first position.
- C. Swap the first and last elements.
- D. Find the highest value and the lowest value in the list.
Answer: B
Explanation:
Selection sort works by growing a sorted portion of the list one element at a time. The algorithm conceptually divides the array into two regions: asorted prefixon the left and anunsorted suffixon the right. At the beginning, the sorted prefix is empty and the entire list is unsorted. The first step is to consider position 0 as the target location for the smallest element. The algorithm scans the unsorted region (initially the whole list) to find the smallest valueand records its index. That action is exactly what option C describes: determine the lowest value starting from the first position.
After identifying the minimum element, selection sort swaps it into position 0 (if it isn't already there). Then it repeats the process for position 1, scanning the remaining unsorted suffix to find the next smallest element, swapping it into place, and so on. Textbooks emphasize that the key characteristic of selection sort is the repeated "select min (or max) from unsorted region and place it into the sorted region." Option A is not the standard first step; finding both min and max is unnecessary. Option B describes an unrelated swap that doesn't ensure progress toward sorting. Option D is not a "first step" but rather a different ordering goal; selection sort can be adapted for descending order, but the canonical version begins by selecting the minimum for the first position.
NEW QUESTION # 31
Which statement describes the relationship between trees and graphs?
- A. Trees do not have levels.
- B. Trees can have unconnected nodes.
- C. Trees can have cycles.
- D. Trees cannot have cycles.
Answer: D
Explanation:
In discrete mathematics and computer science, atreeis a special kind ofgraph. The standard graph-theory definition is that a tree is aconnected, acyclicundirected graph. "Acyclic" means it containsno cycles, i.e., you cannot start at a vertex, follow a sequence of edges, and return to the starting vertex without repeating edges in a way that forms a loop. (Wikipedia) This property is exactly what makes option D correct.
The other options contradict the definition. If a structure has cycles, it is not a tree (though it may still be a graph). If it has unconnected nodes, it is not connected; such a structure is more like aforest(a disjoint union of trees) rather than a single tree. (Wikipedia) The idea of "levels" belongs to a particular computer-science representation called arooted tree, where one node is chosen as the root and nodes can be assigned depths
/levels based on distance from the root. But levels are not required in the abstract definition of a tree as a graph; they arise from choosing a root and orientation for convenience in algorithms like BFS/DFS, heaps, and parse trees.
So, the relationship is: every tree is a graph with extra structure-specifically, no cycles and (typically) connectivity-and the "no cycles" rule is the key distinguishing feature. (Discrete Mathematics)
NEW QUESTION # 32
Which type of files are meant to be inaccessible to standard users, but can be critical in terms of functionality?
- A. Log files
- B. System files
- C. Backup files
- D. Extension files
Answer: B
Explanation:
Operating systems contain many files that are essential for booting, hardware support, security enforcement, and core services. These are generally referred to assystem files. Textbooks explain that system files are often protected by permissions and special attributes because accidental modification or deletion could destabilize the OS, break device drivers, prevent applications from running, or even stop the machine from booting.
Therefore, standard (non-administrator) users are typically restricted from accessing or altering them, and the OS may hide them by default to reduce the risk of user error.
Examples include kernel-related components, shared libraries, driver files, configuration databases, and critical service executables. Modern OS designs enforce protection through user accounts, access control lists, and privilege separation. This ensures only trusted processes and administrators can change system-critical components.
Log files record events and are sometimes protected, but many logs are readable by users or administrators depending on policy; they are not necessarily "meant to be inaccessible" in the same strict sense. Backup files are important for recovery but are not inherently system-critical for day-to-day operation, and their accessibility depends on organizational policy. "Extension files" is not a standard category; file extensions describe formats rather than a protected functional class.
Thus, the files intended to be inaccessible to standard users yet critical for functionality are system files, reflecting core OS security principles such as least privilege and integrity protection.
NEW QUESTION # 33
What is the expected output of numpy_array[1]?
- A. The first element of the array
- B. The second element of the array
- C. A display of the entire array
- D. An error message in the array
Answer: B
Explanation:
In Python and NumPy, indexing iszero-based, meaning the first element of a 1D sequence is at index 0, the second element is at index 1, and so on. A NumPy array behaves like a sequence for basic indexing, so numpy_array[1] returns the element stored at position 1 in the array. This is a fundamental concept taught in introductory programming and scientific computing: indexing selects a single element, while slicing selects a range.
For example, if numpy_array = np.array([5, 8, 13]), then numpy_array[0] is 5, numpy_array[1] is 8, and numpy_array[2] is 13. The expression numpy_array[1] therefore evaluates to thesecond element(8 in this example). This does not display the entire array (that would happen with print(numpy_array)), and it does not produce an error unless the array is too short. An error such as IndexError occurs only if index 1 is out of bounds, for example when the array has length 1 and you try to access numpy_array[1].
Textbooks emphasize careful reasoning about indices because off-by-one errors are common. In data analysis, correct indexing is crucial for extracting the right observations, features, or time steps from numerical datasets.
NEW QUESTION # 34
What Python code would return the value 40 from np_2d, where np_2d = np.array([[1, 2, 3, 4], [10, 20, 30,
40]])?
- A. np_2d[0, 4]
- B. np_2d[4, 1]
- C. np_2d[1, 3]
- D. np_2d[3, 1]
Answer: C
Explanation:
In a 2D NumPy array, indexing is written as array[row_index, column_index] using zero-based indices. The array np_2d = np.array([[1, 2, 3, 4], [10, 20, 30, 40]]) has two rows (indices 0 and 1) and four columns (indices 0, 1, 2, 3). The value 40 is located in the second row and the fourth column. Using zero-based indexing, that corresponds to row index 1 and column index 3. Therefore, np_2d[1, 3] returns 40.
Option A attempts to access row 3, which does not exist and would raise an IndexError. Option C attempts to access column 4 in row 0, but valid column indices are only 0 through 3, so it would also error. Option D likewise refers to a non-existent row 4. Only option B uses valid indices and points to the correct location.
Textbooks emphasize multi-dimensional indexing because it underlies matrix operations, dataset manipulation, and feature extraction in data science. Correctly interpreting rows and columns is essential when rows represent observations (like people) and columns represent attributes (like age, weight, height). This question tests precise control over row/column addressing, which prevents subtle bugs in numerical analysis.
NEW QUESTION # 35
Which sorting algorithm works by finding the smallest or largest element in an unsorted part of a list and moving it to the sorted part of the list?
- A. Selection sort
- B. Quicksort
- C. Radix sort
- D. Heap sort
Answer: A
Explanation:
Selection sort is defined by a simple repeated strategy: divide the list into a sorted region and an unsorted region, then repeatedly select the smallest (or largest) element from the unsorted region and move it to the end of the sorted region. In the common "smallest-first" version, the algorithm scans the unsorted portion to find the minimum element, then swaps it into the next position in the sorted portion. After the first pass, the smallest element is fixed at index 0; after the second pass, the second-smallest is fixed at index 1; and so on until the entire list is sorted.
This exactly matches the description in the question, making selection sort the correct answer. Textbooks often use selection sort to teach algorithmic thinking because it is easy to understand and implement, though not efficient for large datasets. Its time complexity is O(n²) in the average and worst case because it performs roughly n scans of progressively smaller unsorted sections, with each scan taking linear time. Its space usage is O(1) additional space because it sorts in place using swaps.
The other options do not match the described mechanism. Quicksort partitions around a pivot, heap sort uses a heap data structure to repeatedly extract the maximum/minimum, and radix sort processes digits/keys by place value rather than selecting minima by scanning. Selection sort's defining action is the repeated "select the min/max and place it."
NEW QUESTION # 36
Which process is designed to establish the identity of the user such as with a username and password?
- A. Registration
- B. Authentication
- C. Verification
- D. Certification
Answer: B
Explanation:
Authenticationis the security process of proving or establishing a user's identity. In textbook terminology, authentication answers the question: "Who are you?" Common authentication factors include something you know (password, PIN), something you have (smart card, hardware token), and something you are (biometrics). Username and password is the classic "something you know" mechanism, where the username identifies the account and the password serves as a secret used to validate that the user is the rightful owner of that account.
Authentication is distinct fromauthorization, which determines what an authenticated user is allowed to do (permissions, roles). It is also distinct from registration, which is the administrative act of creating an account or enrolling a user in a system. "Verification" is a general term that can appear in many contexts, but in security frameworks the precise term for identity establishment is authentication. "Certification" usually refers to issuing or validating credentials such as digital certificates (PKI) or professional certifications, not the act of logging in with a password.
Textbooks emphasize that authentication should be strengthened with practices like hashing and salting passwords, multi-factor authentication (MFA), lockout policies, and secure transport (e.g., TLS) to prevent credential theft. The core concept remains: the process that establishes identity using credentials like a username and password is authentication.
NEW QUESTION # 37
......
Foundations-of-Computer-Science Exam Dumps - PDF Questions and Testing Engine: https://www.actualtestsquiz.com/Foundations-of-Computer-Science-test-torrent.html
Real Foundations-of-Computer-Science Exam Dumps Questions Valid Foundations-of-Computer-Science Dumps PDF: https://drive.google.com/open?id=1tB3ukFcgCx4EvVccrosOUt436pcGa1Az

