Unit 3: Using RDD for Creating Applications in Spark and Graph Analytics - Practice Quiz

INT315 — Cluster Computing 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does RDD stand for in Apache Spark?

Features of RDD Easy
A. Remote Distributed Directory
B. Resilient Data Dictionary
C. Reliable Dynamic Database
D. Resilient Distributed Dataset

2 Which property means that an RDD cannot be changed after it is created?

Features of RDD Easy
A. Immutability
B. Replication
C. Serialization
D. Scalability

3 Which Spark method creates an RDD from a local collection?

Creating RDDs Easy
A. broadcast()
B. parallelize()
C. collect()
D. persist()

4 Which method is commonly used to create an RDD by reading a text file?

Creating RDDs Easy
A. textFile()
B. wholeTextFiles()
C. saveAsTextFile()
D. objectFile()

5 Which RDD function applies a given function to every element?

RDD functions Easy
A. map()
B. count()
C. reduce()
D. filter()

6 Which RDD function keeps only the elements that satisfy a condition?

RDD functions Easy
A. flatMap()
B. union()
C. filter()
D. first()

7 Which of the following is an RDD action?

RDD operations and methods Easy
A. collect()
B. map()
C. distinct()
D. filter()

8 What is lazy evaluation in Spark?

RDD operations and methods Easy
A. RDDs load only after the driver stops
B. Actions run only when a file is saved
C. Transformations run only when an action is called
D. Tasks run only on a single worker

9 Which command normally starts the Spark shell for Scala?

Invoking the Spark shell Easy
A. pyspark
B. spark-shell
C. spark-start
D. spark-submit

10 Which command normally starts the interactive Spark shell for Python?

Invoking the Spark shell Easy
A. pyspark
B. spark-python
C. python-spark
D. spark-shell

11 Which shared variable efficiently sends a read-only value to all worker nodes?

Shared variables Easy
A. Broadcast variable
B. Accumulator variable
C. Partition variable
D. Local variable

12 Which Spark shared variable is commonly used to add values across tasks?

Shared variables Easy
A. Accumulator
B. DataFrame
C. Broadcast
D. Partitioner

13 What type of data is Spark GraphX designed to process?

Introduction to Spark GraphX Easy
A. Spreadsheet data
B. Audio data
C. Graph data
D. Image data

14 What are the two basic components of a graph in GraphX?

Introduction to Spark GraphX Easy
A. Files and blocks
B. Rows and columns
C. Keys and tables
D. Vertices and edges

15 Which Spark capability can GraphX use for distributed graph processing?

Spark GraphX features Easy
A. RDD-based computation
B. Browser-side storage
C. Single-node execution
D. Manual file copying

16 Which built-in GraphX algorithm ranks important vertices in a graph?

Spark GraphX features Easy
A. Naive Bayes
B. PageRank
C. K-means
D. Linear regression

17 Which GraphX operation creates a new graph by changing vertex attributes?

Spark GraphX operations Easy
A. reverse()
B. subgraph()
C. mapVertices()
D. mapEdges()

18 Which GraphX operation produces a graph with the direction of every edge reversed?

Spark GraphX operations Easy
A. subgraph()
B. groupEdges()
C. mapTriplets()
D. reverse()

19 What is the main purpose of feature extraction in machine learning?

Feature extraction and transformation Easy
A. Remove every column from data
B. Send results to worker nodes
C. Store raw data in graph edges
D. Convert raw data into useful features

20 Which Spark ML transformer converts a text document into a vector of token counts?

Feature extraction and transformation Easy
A. CountVectorizer
B. Bucketizer
C. StringIndexer
D. StandardScaler

21 A Spark application applies several transformations to an RDD and then executes an action. Which RDD feature allows Spark to recompute only lost partitions instead of copying all data?

Features of RDD Medium
A. Partition-level lineage
B. Global data replication
C. Immediate transformation execution
D. Centralized memory storage

22 Why are RDDs particularly useful for iterative machine-learning algorithms?

Features of RDD Medium
A. They eliminate the need for transformations
B. They automatically remove all duplicate records
C. They store every result permanently on disk
D. They cache intermediate data in memory

23 Which expression creates an RDD from a local collection in PySpark?

Creating RDDs Medium
A. sc.create([1, 2, 3])
B. sc.collect([1, 2, 3])
C. sc.distribute([1, 2, 3])
D. sc.parallelize([1, 2, 3])

24 A text file is stored in HDFS at /data/logs.txt. Which PySpark statement creates an RDD whose records normally represent lines from the file?

Creating RDDs Medium
A. sc.loadText("/data/logs.txt")
B. sc.textFile("/data/logs.txt")
C. sc.fileRDD("/data/logs.txt")
D. sc.readFile("/data/logs.txt")

25 Given rdd = sc.parallelize([1, 2, 3, 4]), which expression returns [2, 4, 6, 8] as an RDD?

RDD functions Medium
A. rdd.groupBy(lambda x: x * 2)
B. rdd.reduce(lambda x, y: x * 2)
C. rdd.map(lambda x: x * 2)
D. rdd.filter(lambda x: x * 2)

26 An RDD contains sentences, and the goal is to produce one record for every word. Which transformation is most appropriate?

RDD functions Medium
A. filter(lambda line: line.split())
B. reduce(lambda line: line.split())
C. map(lambda line: line.split())
D. flatMap(lambda line: line.split())

27 Given pair RDD records such as ("A", 3) and ("A", 5), which transformation produces the total value for each key?

RDD functions Medium
A. filterByKey(lambda a, b: a + b)
B. mapValues(lambda a, b: a + b)
C. reduceByKey(lambda a, b: a + b)
D. groupByKey(lambda a, b: a + b)

28 What is the result of calling rdd.count() on an RDD containing five records?

RDD operations and methods Medium
A. A list containing the five records
B. The integer 5
C. The first record in the RDD
D. An RDD with five partitions

29 Why does rdd.map(lambda x: x * 2) usually not execute immediately?

RDD operations and methods Medium
A. It is blocked by the driver
B. It is a lazy transformation
C. It requires a broadcast variable
D. It can run only on pair RDDs

30 Which method should be used when an RDD will be reused by multiple actions and should remain available in memory when possible?

RDD operations and methods Medium
A. unpersistBeforeUse()
B. checkpointOnly()
C. persist()
D. destroy()

31 A developer wants to inspect all elements of a small RDD on the driver. Which action is appropriate?

RDD operations and methods Medium
A. partitionBy()
B. distribute()
C. parallelize()
D. collect()

32 Which command starts the Scala-based Spark shell with the Spark context commonly available as sc?

Invoking the Spark shell Medium
A. scala-spark-submit
B. spark-shell
C. spark-submit-shell
D. start-spark-scala

33 Which command is normally used to start the Python version of the Spark interactive shell?

Invoking the Spark shell Medium
A. spark-python
B. python-spark-shell
C. pyspark
D. spark-submit --interactive

34 A large read-only lookup table is needed by tasks on many executors. Which shared variable avoids sending a separate copy with every task?

Shared variables Medium
A. Broadcast variable
B. Temporary view
C. Checkpoint directory
D. Accumulator variable

35 Which shared variable is appropriate for counting invalid records across tasks?

Shared variables Medium
A. Broadcast variable
B. Spark session
C. Accumulator
D. RDD partition

36 In GraphX, a graph is primarily represented as which combination of distributed datasets?

Introduction to Spark GraphX Medium
A. Vertex and edge RDDs
B. Keys and accumulators
C. Files and broadcast maps
D. Rows and columns

37 Which GraphX feature allows graph algorithms to combine graph structure with distributed data processing?

Spark GraphX features Medium
A. Execution only on one machine
B. Mandatory conversion to relational tables
C. Integration with Spark RDDs
D. Removal of vertex attributes

38 Which GraphX operation creates a new graph by retaining only vertices and edges that satisfy a predicate?

Spark GraphX operations Medium
A. subgraph
B. aggregateMessages
C. collectNeighbors
D. outerJoinVertices

39 Which GraphX operation is designed to send messages along edges and aggregate messages at destination vertices?

Spark GraphX operations Medium
A. triangleCount
B. connectedComponents
C. reverse
D. aggregateMessages

40 A dataset contains the categorical values red, blue, and green. Which transformation is commonly used before applying a machine-learning algorithm that requires numeric input?

Feature extraction and transformation Medium
A. One-hot encoding
B. Graph reversal
C. Random partitioning
D. RDD checkpointing

41 An RDD is persisted using MEMORY_ONLY. After several partitions are cached, an executor holding one cached partition fails. The original data is still available in HDFS. What occurs when an action next requires the lost partition?

Features of RDD Hard
A. Spark recomputes every partition and replaces the entire cached RDD.
B. Spark recomputes only the lost partition using the RDD lineage.
C. Spark aborts because cached partitions cannot be reconstructed after executor loss.
D. Spark reads a replicated cache copy maintained automatically by MEMORY_ONLY.

42 A pair RDD already has a HashPartitioner named p. Which transformation sequence preserves that partitioner, allowing a subsequent reduceByKey(p, f) to avoid an unnecessary reshuffle?

Features of RDD Hard
A. rdd.map(kv => (kv._1, g(kv._2))).filter(predicate)
B. rdd.keyBy(kv => normalize(kv._1)).mapValues(g)
C. rdd.mapPartitions(iter => iter.map(transform), preservesPartitioning = false)
D. rdd.mapValues(g).filter(predicate)

43 A directory contains thousands of small UTF-8 files. An application must create an RDD in which each record contains one file's path and its complete contents, rather than one record per line. Which creation method directly provides this representation?

Creating RDDs Hard
A. sc.binaryRecords(path, recordLength)
B. sc.wholeTextFiles(path)
C. sc.textFile(path).zipWithIndex()
D. sc.sequenceFile(path)

44 Two ordinary RDDs without partitioners are created as a = sc.parallelize(dataA, 3) and b = sc.parallelize(dataB, 5). What is normally true of a.union(b) before any later repartitioning?

Creating RDDs Hard
A. It has three partitions and a shuffle dependency on b.
B. It has five partitions and a shuffle dependency on a.
C. It has eight partitions and narrow dependencies on both parents.
D. It has eight partitions and wide dependencies on both parents.

45 An RDD has exactly two partitions containing [1, 2] and [3, 4]. What does rdd.aggregate(10)((x, y) => x + y, (x, y) => x + y) return?

RDD functions Hard
A. 40
B. 50
C. 30
D. 20

46 Suppose empty is an RDD with no elements but several empty partitions. Which statement correctly distinguishes empty.fold(0)(_ + _) from empty.reduce(_ + _)?

RDD functions Hard
A. fold and reduce both fail because every partition is empty.
B. fold fails, whereas reduce infers and returns the integer identity.
C. fold returns 0, whereas reduce fails because no element exists.
D. fold and reduce both return 0 because addition has an identity.

47 Two RDDs have the same total element count and the same number of partitions, but corresponding partitions contain different numbers of elements. What happens when left.zip(right) is evaluated?

RDD operations and methods Hard
A. It fails because corresponding partitions must have equal element counts.
B. It succeeds after automatically repartitioning both RDDs by element index.
C. It truncates each partition pair to the smaller local element count.
D. It succeeds by moving excess elements into each following partition.

48 An RDD currently has four partitions. The application executes rdd.coalesce(8, shuffle = false) and, separately, rdd.repartition(8). What partition counts should be expected?

RDD operations and methods Hard
A. coalesce keeps four, while repartition creates eight.
B. Both operations keep four because partitions cannot be increased.
C. Both operations create eight without introducing a shuffle.
D. coalesce creates eight, while repartition keeps four.

49 A developer launches spark-shell --master local[2]. Assuming tasks are otherwise runnable and each task uses one CPU, what does the master setting primarily permit?

Invoking the Spark shell Hard
A. Two executor JVMs plus a separate cluster-manager process.
B. Exactly two partitions to be created for every new RDD.
C. Up to two tasks to execute concurrently in one local JVM.
D. Two worker processes, each using every core on the machine.

50 A Spark shell requires an GB driver heap. Which approach configures this reliably?

Invoking the Spark shell Hard
A. Launch it using spark-shell --driver-memory 8g.
B. Assign spark.conf.set("spark.driver.memory", "8g") after creating an RDD.
C. Execute spark.sql("SET spark.driver.memory=8g") inside the shell.
D. Run sc.getConf.set("spark.driver.memory", "8g") after startup.

51 An accumulator is incremented inside a lazy map transformation, and the transformed RDD is evaluated by two separate actions without persistence. Why is the accumulator unsuitable for reporting an exact number of input records?

Shared variables Hard
A. Each partition replaces the accumulator value instead of merging its updates.
B. Accumulators accept updates only from actions and ignore updates inside transformations.
C. Each action may recompute the transformation and increment the accumulator again.
D. Accumulator updates are visible to executors but never returned to the driver.

52 A large lookup table is distributed using a broadcast variable. The driver later creates a substantially updated version that future tasks must use. What is the appropriate design?

Shared variables Hard
A. Create a new broadcast and release the old broadcast when it is no longer used.
B. Mutate the object returned by the existing broadcast's value field on the driver.
C. Update the table through an accumulator and read the accumulator from each executor.
D. Modify one executor's local copy and allow Spark to propagate the changes automatically.

53 A GraphX graph is constructed with a vertex RDD containing only vertex 1, an edge from vertex 1 to vertex 2, and "unknown" as the default vertex attribute. How is vertex 2 represented?

Introduction to Spark GraphX Hard
A. Graph construction fails because every edge endpoint must be predefined.
B. It is added with the same attribute as source vertex 1.
C. It is added to the graph with the attribute "unknown".
D. It is omitted, and the edge is silently removed from the graph.

54 Which information is available directly from each element of a GraphX graph's triplets view?

Introduction to Spark GraphX Hard
A. Edge attribute, partition identifier, and global in-degree of each endpoint.
B. Source attribute, destination attribute, and the shortest path between them.
C. Source ID and attribute, destination ID and attribute, and edge attribute.
D. Source ID, destination ID, and attributes of every neighboring vertex.

55 A graph contains many parallel edges in both directions between the same pairs of vertices. Which GraphX partition strategy hashes the canonicalized endpoint pair so that direction-reversed edges for a pair are assigned consistently?

Spark GraphX features Hard
A. RandomVertexCut
B. EdgePartition2D
C. CanonicalRandomVertexCut
D. EdgePartition1D

56 A GraphX subgraph operation receives both a vertex predicate and an edge-triplet predicate. Which statement describes the resulting graph?

Spark GraphX features Hard
A. It retains only vertices incident to an edge accepted by the edge predicate.
B. It retains accepted edges even when one endpoint fails the vertex predicate.
C. It retains every vertex but replaces rejected edges with zero-valued edges.
D. It retains accepted vertices and accepted edges whose two endpoints are retained.

57 A graph has weighted edges (1,2,3), (3,2,5), and (2,3,7), where each tuple is (source, destination, weight). aggregateMessages sends each edge's weight only to its destination and merges messages using addition. Which result is produced?

Spark GraphX operations Hard
A. Vertex 1 receives 3, vertex 2 receives 12, and vertex 3 receives 12.
B. Vertex 2 receives 5, vertex 3 receives 7, and vertex 1 receives 3.
C. Vertex 2 receives 8, vertex 3 receives 7, and vertex 1 is absent.
D. Vertex 1 receives 0, vertex 2 receives 8, and vertex 3 receives 7.

58 An auxiliary RDD[(VertexId, U)] has data for only some graph vertices. Which operation invokes an update function for every graph vertex while representing a missing auxiliary value with None?

Spark GraphX operations Hard
A. mapTriplets
B. joinVertices
C. outerJoinVertices
D. mapVertices

59 A text pipeline applies HashingTF with a small numFeatures value and then fits IDF. Two frequent terms collide into the same hash index. What is the consequence?

Feature extraction and transformation Hard
A. IDF detects the collision and creates a new feature index for the less frequent term.
B. HashingTF stores both terms separately in the same vector position using nested values.
C. The colliding terms are discarded because a feature index may represent only one term.
D. Their counts and document-frequency evidence share one feature and cannot be separated by IDF.

60 A dataset contains million-dimensional vectors with only a few nonzero entries per row. What is the principal risk of applying StandardScaler with withMean = true?

Feature extraction and transformation Hard
A. Mean centering preserves sparsity but changes every feature into a binary indicator.
B. Mean centering hashes multiple dimensions into the same output coordinate.
C. Mean centering removes all zero-variance dimensions before scaling begins.
D. Mean centering can convert sparse vectors into dense vectors and exhaust memory.