SlideShare a Scribd company logo
1 of 1
Download to read offline
1: function algorithm(A, k)
2: n length of A
3: B new array of size n k
4: for i [0 : n k] do i ranges from 0 to n k 1
5: B[i] 0
6: for j [0 : k] do j ranges from 0 to k 1
7: B[i] B[i] + A[i + j]
8: return B
Assuming that k < n/2 (but not necessarily a constant) use O-notation to upperbound
the running time of the following algorithm in terms of both n and k.
Consider the following algorithm that given an array A of length n produces another array B of
length nk where B[i]=j=ii+k1A[j]. Assuming that k

More Related Content

More from alphawheels007

1) Select the correct order for the steps of corporate social respon.pdf
1) Select the correct order for the steps of corporate social respon.pdf1) Select the correct order for the steps of corporate social respon.pdf
1) Select the correct order for the steps of corporate social respon.pdfalphawheels007
 
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdfalphawheels007
 
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdfalphawheels007
 
1) Run the systemctl status httpd command to show that your web se.pdf
1) Run the systemctl status httpd command to show that your web se.pdf1) Run the systemctl status httpd command to show that your web se.pdf
1) Run the systemctl status httpd command to show that your web se.pdfalphawheels007
 
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdfalphawheels007
 
1) In the study of an outbreak of an infectious disease, plotting an.pdf
1) In the study of an outbreak of an infectious disease, plotting an.pdf1) In the study of an outbreak of an infectious disease, plotting an.pdf
1) In the study of an outbreak of an infectious disease, plotting an.pdfalphawheels007
 
1) Install and run an Apache secure web server on your Linux OS. 2) .pdf
1) Install and run an Apache secure web server on your Linux OS. 2) .pdf1) Install and run an Apache secure web server on your Linux OS. 2) .pdf
1) Install and run an Apache secure web server on your Linux OS. 2) .pdfalphawheels007
 
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdfalphawheels007
 
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdfalphawheels007
 
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdfalphawheels007
 
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdfalphawheels007
 
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdfalphawheels007
 
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdfalphawheels007
 
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdfalphawheels007
 
1) El n�mero total de especies en una comunidad se llama especie ___.pdf
1) El n�mero total de especies en una comunidad se llama especie ___.pdf1) El n�mero total de especies en una comunidad se llama especie ___.pdf
1) El n�mero total de especies en una comunidad se llama especie ___.pdfalphawheels007
 
-please use chens notations for the diagram-your conceptual schema.pdf
-please use chens notations for the diagram-your conceptual schema.pdf-please use chens notations for the diagram-your conceptual schema.pdf
-please use chens notations for the diagram-your conceptual schema.pdfalphawheels007
 
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdfalphawheels007
 
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdfalphawheels007
 
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdfalphawheels007
 

More from alphawheels007 (20)

1) Select the correct order for the steps of corporate social respon.pdf
1) Select the correct order for the steps of corporate social respon.pdf1) Select the correct order for the steps of corporate social respon.pdf
1) Select the correct order for the steps of corporate social respon.pdf
 
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf
1) Las especies con tiempos de generaci�n m�s largos deben tener .pdf
 
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf
1) Seg�n Henri Fayol, los planes efectivos deben tener las cualidade.pdf
 
1) Run the systemctl status httpd command to show that your web se.pdf
1) Run the systemctl status httpd command to show that your web se.pdf1) Run the systemctl status httpd command to show that your web se.pdf
1) Run the systemctl status httpd command to show that your web se.pdf
 
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf
1) La siguiente oraci�n tiene errores, podr�a ser prolija, entrecort.pdf
 
1) In the study of an outbreak of an infectious disease, plotting an.pdf
1) In the study of an outbreak of an infectious disease, plotting an.pdf1) In the study of an outbreak of an infectious disease, plotting an.pdf
1) In the study of an outbreak of an infectious disease, plotting an.pdf
 
1) Install and run an Apache secure web server on your Linux OS. 2) .pdf
1) Install and run an Apache secure web server on your Linux OS. 2) .pdf1) Install and run an Apache secure web server on your Linux OS. 2) .pdf
1) Install and run an Apache secure web server on your Linux OS. 2) .pdf
 
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf
1) La expresi�n g�nica diferencial ocurre en cada una de las siguien.pdf
 
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf
1) El objetivo del inventario de seguridad es a. reemplace las uni.pdf
 
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf
1) Explicar qu� es la gesti�n de la capacidad y por qu� es estrat�gi.pdf
 
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf
1) En una poblaci�n que est� en equilibrio de Hardy-Weinberg, hay do.pdf
 
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf
1) Eres un estudiante de MPH en pr�cticas en una iglesia local. Part.pdf
 
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf
1) El promedio de transporte Dow Jones originalmente se llamaba prom.pdf
 
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf
1) El �xito de un sitio web se mide por lo bien que a. Genera tr�f.pdf
 
1) El n�mero total de especies en una comunidad se llama especie ___.pdf
1) El n�mero total de especies en una comunidad se llama especie ___.pdf1) El n�mero total de especies en una comunidad se llama especie ___.pdf
1) El n�mero total de especies en una comunidad se llama especie ___.pdf
 
1(23).pdf
1(23).pdf1(23).pdf
1(23).pdf
 
-please use chens notations for the diagram-your conceptual schema.pdf
-please use chens notations for the diagram-your conceptual schema.pdf-please use chens notations for the diagram-your conceptual schema.pdf
-please use chens notations for the diagram-your conceptual schema.pdf
 
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf
1 - Sam, conduciendo bajo la influencia, provoca un accidente automo.pdf
 
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf
1) Assume you have purchased a public IPv4 as follows 192.168.0.01.pdf
 
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf
1) Caffeine is a nonpolar molecule. What is the most likely method b.pdf
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Algorithm to Sum Array Elements Over Sliding Window

  • 1. 1: function algorithm(A, k) 2: n length of A 3: B new array of size n k 4: for i [0 : n k] do i ranges from 0 to n k 1 5: B[i] 0 6: for j [0 : k] do j ranges from 0 to k 1 7: B[i] B[i] + A[i + j] 8: return B Assuming that k < n/2 (but not necessarily a constant) use O-notation to upperbound the running time of the following algorithm in terms of both n and k. Consider the following algorithm that given an array A of length n produces another array B of length nk where B[i]=j=ii+k1A[j]. Assuming that k