Recall & Review
beginner Click to reveal answer
What is character frequency counting?
It is the process of counting how many times each character appears in a given string or text.
beginner Click to reveal answer
Which data structure is commonly used to store character frequencies?
A map or dictionary where keys are characters and values are their counts.
intermediate Click to reveal answer
In Go, which type is best to represent a character frequency map?
map[rune]int because rune represents a Unicode character and int stores the count.
intermediate Click to reveal answer
Why is it important to use 'rune' instead of 'byte' for character frequency counting in Go?
Because 'rune' supports Unicode characters beyond ASCII, while 'byte' only supports single bytes which may not represent full Unicode characters.
beginner Click to reveal answer
What is the time complexity of counting character frequencies in a string of length n?
O(n), because each character is visited once to update its count.
What data structure is best for storing character counts in Go?
✗ Incorrect
map[rune]int stores characters as keys and their counts as values.
Why use 'rune' instead of 'byte' for characters in Go?
✗ Incorrect
'rune' can represent all Unicode characters, 'byte' only ASCII.
What is the output of counting characters in the string "Go!"?
✗ Incorrect
Each character appears once in "Go!".
What is the time complexity of character frequency counting?
✗ Incorrect
Each character is processed once, so O(n).
Which Go keyword is used to declare a map?
✗ Incorrect
'map' declares a map type in Go.
Explain how to count character frequencies in a string using Go.
Think about looping over each character and storing counts in a map.
You got /3 concepts.
Why is using 'rune' important for character frequency counting in Go?
Consider the difference between ASCII and Unicode characters.
You got /3 concepts.
