Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

Why would Web threats see such a drastic six-fold (600%) increase?

Answered: 1 week ago

Question

9.6 Explain what management development is and why it is important.

Answered: 1 week ago

Question

What is the relation of physical mathematics with examples?

Answered: 1 week ago

Question

What are oxidation and reduction reactions? Explain with examples

Answered: 1 week ago