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. Resilient Distributed Dataset
B. Reliable Dynamic Database
C. Resilient Data Dictionary
D. Remote Distributed Directory

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

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

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

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

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

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

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

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

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

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

7 Which of the following is an RDD action?

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

8 What is lazy evaluation in Spark?

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

9 Which command normally starts the Spark shell for Scala?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. StandardScaler
D. StringIndexer

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. Immediate transformation execution
B. Partition-level lineage
C. Centralized memory storage
D. Global data replication

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

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

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

Creating RDDs Medium
A. sc.collect([1, 2, 3])
B. sc.parallelize([1, 2, 3])
C. sc.distribute([1, 2, 3])
D. sc.create([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.textFile("/data/logs.txt")
B. sc.fileRDD("/data/logs.txt")
C. sc.loadText("/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.map(lambda x: x * 2)
B. rdd.filter(lambda x: x * 2)
C. rdd.groupBy(lambda x: x * 2)
D. rdd.reduce(lambda x, y: 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. flatMap(lambda line: line.split())
B. map(lambda line: line.split())
C. reduce(lambda line: line.split())
D. filter(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. groupByKey(lambda a, b: a + b)
B. reduceByKey(lambda a, b: a + b)
C. filterByKey(lambda a, b: a + b)
D. mapValues(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. An RDD with five partitions
B. The integer 5
C. A list containing the five records
D. The first record in the RDD

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

RDD operations and methods Medium
A. It is a lazy transformation
B. It requires a broadcast variable
C. It is blocked by the driver
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. destroy()
B. persist()
C. unpersistBeforeUse()
D. checkpointOnly()

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. distribute()
B. collect()
C. partitionBy()
D. parallelize()

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. start-spark-scala
C. spark-submit-shell
D. spark-shell

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. pyspark
C. python-spark-shell
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. Temporary view
B. Accumulator variable
C. Checkpoint directory
D. Broadcast variable

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

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

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

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

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. collectNeighbors
B. outerJoinVertices
C. aggregateMessages
D. subgraph

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. aggregateMessages
D. reverse

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. Graph reversal
B. Random partitioning
C. One-hot encoding
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 aborts because cached partitions cannot be reconstructed after executor loss.
B. Spark reads a replicated cache copy maintained automatically by MEMORY_ONLY.
C. Spark recomputes only the lost partition using the RDD lineage.
D. Spark recomputes every partition and replaces the entire cached RDD.

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.mapValues(g).filter(predicate)
B. rdd.keyBy(kv => normalize(kv._1)).mapValues(g)
C. rdd.mapPartitions(iter => iter.map(transform), preservesPartitioning = false)
D. rdd.map(kv => (kv._1, g(kv._2))).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.textFile(path).zipWithIndex()
C. sc.sequenceFile(path)
D. sc.wholeTextFiles(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 five partitions and a shuffle dependency on a.
B. It has three partitions and a shuffle dependency on b.
C. It has eight partitions and wide dependencies on both parents.
D. It has eight partitions and narrow 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. 30
B. 40
C. 50
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 fails, whereas reduce infers and returns the integer identity.
B. fold and reduce both fail because every partition is empty.
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 by moving excess elements into each following partition.
C. It succeeds after automatically repartitioning both RDDs by element index.
D. It truncates each partition pair to the smaller local element count.

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. coalesce creates eight, while repartition keeps four.
C. Both operations create eight without introducing a shuffle.
D. Both operations keep four because partitions cannot be increased.

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. Exactly two partitions to be created for every new RDD.
B. Two executor JVMs plus a separate cluster-manager process.
C. Two worker processes, each using every core on the machine.
D. Up to two tasks to execute concurrently in one local JVM.

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

Invoking the Spark shell Hard
A. Execute spark.sql("SET spark.driver.memory=8g") inside the shell.
B. Launch it using spark-shell --driver-memory 8g.
C. Assign spark.conf.set("spark.driver.memory", "8g") after creating an RDD.
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. Each action may recompute the transformation and increment the accumulator again.
C. Accumulators accept updates only from actions and ignore updates inside transformations.
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. Modify one executor's local copy and allow Spark to propagate the changes automatically.
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. Create a new broadcast and release the old broadcast when it is no longer used.

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. It is added with the same attribute as source vertex 1.
B. It is omitted, and the edge is silently removed from the graph.
C. Graph construction fails because every edge endpoint must be predefined.
D. It is added to the graph with the attribute "unknown".

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

Introduction to Spark GraphX Hard
A. Source attribute, destination attribute, and the shortest path between them.
B. Edge attribute, partition identifier, and global in-degree of each endpoint.
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. EdgePartition1D
B. RandomVertexCut
C. EdgePartition2D
D. CanonicalRandomVertexCut

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 accepted vertices and accepted edges whose two endpoints are retained.
B. It retains every vertex but replaces rejected edges with zero-valued edges.
C. It retains accepted edges even when one endpoint fails the vertex predicate.
D. It retains only vertices incident to an edge accepted by the edge predicate.

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. mapVertices
C. outerJoinVertices
D. joinVertices

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. Their counts and document-frequency evidence share one feature and cannot be separated by IDF.
C. HashingTF stores both terms separately in the same vector position using nested values.
D. The colliding terms are discarded because a feature index may represent only one term.

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 can convert sparse vectors into dense vectors and exhaust memory.
B. Mean centering preserves sparsity but changes every feature into a binary indicator.
C. Mean centering hashes multiple dimensions into the same output coordinate.
D. Mean centering removes all zero-variance dimensions before scaling begins.