Question
Suppose I have a text file contain the charaters a,b,c,d in random order. there are over a million characters in the file. I want to
Suppose I have a text file contain the charaters a,b,c,d in random order. there are over a million characters in the file. I want to find how many a's, b's, c's and d's this file contains. One way I can do it is read in the file store in an array and loop through the array. This way will give the program an excution time of o(n). When working with a big file, this is not efficient. What's the best algorithm to complete this task?
one way I can think of is Let a=0, b=1, c=2 and d=3 (i.e. think about letters as digits),but not sure how to implenment using c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started