Question

In: Computer Science

Hello, for c++, please expert tell me how to use unordered set to do the rest...

Hello, for c++, please expert tell me how to use unordered set to do the rest method:insert, remove, find in container, declaration, visiting all elements.

Solutions

Expert Solution

1 . >

Inserting elements into unordered_Set :

CONCEPT : used a function st.insert() function of unordered_set<int>st name st.

C++ code to show how to insert element into unordered_set

NOTE: I have inserted {9,2,8,5,2 } these elements into unordered_set set but our set will only
contains only unique elements. In these elements 2 is repeated so set will contains 2 only 1 times.
so finally  unordered_set contains = {9,2,8,5} these elements.

2.>

Removal of particular elements from unordered_Set :

CONCEPT : used st.find(x) , this function will find the position of element x from set and give iterator pointing to x and once we find the iterator we will use st.erase(it) to remove that element from set.

C++ code to show how to remove element from unordered_set

3.>

st.find(x) to find element in unordered_set , below is the explained code with output

test case1:

please enter the number you want to search in unordered_set :

8

Output :

8 is not found is unordered_set

test case2:

please enter the number you want to search in unordered_set :

3

Output :

3 is present in unordered_set

Time complexity :

Insertion , removal , these all takes O(1) , constant time in best and average case in unordered_Set but in worst case time compelxity may be  linear time O(n) which depends on the internally used hash function,


Related Solutions

Hello, I was wondering if you could tell me how to do a general Ledger? I...
Hello, I was wondering if you could tell me how to do a general Ledger? I just finish doing a Sales Journal, Purchase Journal, Cash Receipt Journal, Cash Disbursements Journal and a General Journal under one company Sound Bytes Electronics). What I wanted to know is do I use the General Journal to do the General Ledger? Or do I use the Special Journals and the General Journal to do the General Ledger? Can you put me in the right...
Please tell me how to solve the following questions a) to c) using a graph. In...
Please tell me how to solve the following questions a) to c) using a graph. In particular, please elaborate on c). Cellwave is a cellular phone company. Answer the following questions relating to its pricing policies: a) When Cellwave started, it sold to a group of homogeneous retail customers. Each person’s monthly demand for cell phone minutes was given by P = $2 - 0.02Q , where P = the price per minute and Q = the quantity of minutes...
Hello, Please give me step by step solution (screenshot) on how to use the SPSS to...
Hello, Please give me step by step solution (screenshot) on how to use the SPSS to solve the following: To examine the work environment on attitude toward work, an industrial hygienist randomly assigns a group of 18 recently hired sales trainees to three "home rooms" - 6 trainees per room. Each room is identical except for wall color. One is light green, another is light blue, and the third is a deep red. During the week-long training program, the trainees...
Before doing this please tell me what is lift factor and tell me how did we...
Before doing this please tell me what is lift factor and tell me how did we calculate seasonal index for carlson's sales of january as 0.957 The Carlson Department store suffered heavy damage when a hurricane struck on August 31. The store was closed for four months (September through December), and Carlson is now involved in a dispute with its insurance company about the amount of lost sales during the time the store was closed. Two key issues must be...
please show me or tell me a trick, on how can i tell right away when...
please show me or tell me a trick, on how can i tell right away when a characteristics equation(system) is 1)overdamped 2)underdamped 3)critically damped 4) nonlinear show each an example write neatly!!!!!
please tell me how to write proofs for diophantine equation
please tell me how to write proofs for diophantine equation
Hello, please tell me about your favorite movie! select ANY movie of your choice and analyze...
Hello, please tell me about your favorite movie! select ANY movie of your choice and analyze the movie from the perspective of developmental psychology. You will discuss the themes, plot, characters, and conflict in the movie. You will tie these elements of the movie to theories, topics, and information covered in this course. The paper should demonstrate your broad and comprehensive understanding of the field of Developmental Psychology.
hello, please tell me what you think about my twi discussion post about intelligence DISCUSSION 1...
hello, please tell me what you think about my twi discussion post about intelligence DISCUSSION 1 I believe genes do not determine intelligence. Intelligence and genes have very little to do with one another. Genes are what give us our traits such as; eye color and hair color. Knowledge and information develop and grows over time. As an example, two intelligent parents have two children, one that goes to school and one that does not. The child that can develop...
What role do exhibits play in the expert report? How can the expert use them to...
What role do exhibits play in the expert report? How can the expert use them to make the report more persuasive to the judge and jury? Are there any risks in using exhibits?
Please analyze this company financial and briefly tell me how they are performing and areas of...
Please analyze this company financial and briefly tell me how they are performing and areas of concern Southwest Airlines Co. Condensed Consolidated Statement of Income (in millions, except per share amounts) (unaudited) Three months ended March 31, 2017 2018 As Recast Percent Change OPERATING REVENUES: Passenger $ 4,585 $ 4,546 0.9 Freight 42 42 — Other 317 266 19.2      Total operating revenues 4,944 4,854 1.9 OPERATING EXPENSES: Salaries, wages, and benefits 1,821 1,730 5.3 Fuel and oil 1,018 956 6.5...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT